1.0.8 • Published 2 years ago

create-kernode v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Kernode

  • Slim Node js framework with typescript

Collaborator are welcome

  • Fork repository and create PR to develop branch

npm init kernode

Packages Used

HTTP Routes

  • routes/web.ts
  • routes/api.ts

  • api

import { ApiRouter as Router } from '@kernode/core'
import ApiController from 'Controller/Http/ApiController'

Router.get('/', ApiController.index)
  • web
import { Router } from '@kernode/core'
import WebController from 'Controller/Http/WebController'

Router.get('/', WebController.index)

Socket

  • routes/socket.ts
import { SocketListener } from '@kernode/core'
import WebSocketController from 'Controller/Ws/WebSocketController'

SocketListener.on('message', WebSocketController.onMessage)

Event Emitter

  • routes/event.ts
import { EventListener } from '@kernode/core'
import EventController from 'Controller/Event/EventController'

EventListener.on('message', EventController.onMessage)
  • Emit from Controller using AppEventEmitter
import { AppEventEmitter } from '@kernode/core'
AppEventEmitter.emit('message', { vehicle: 'car' })

Database Migration

Models

import { Model } from '@kernode/core'

class User extends Model {
  tableName: string = 'users'

  id: string
  name: string
  email: string
  password: string
  created_at: string
  updated_at: string
}

export default new User()
let users = await User.query().where('id', 1)

Authentication

Hash

  • Hash.make('plainPasswordText') (string)

  • Hash.verify('plainPasswordText', hashedString) (bool)

Jwt Auth

  • Auth.token(userObjectPayload) (jwt token)

  • Auth.verify(userObjectPayload) (User Object Payload | false)

Storage (support Local and AWS S3)

  • Storage.store(file) path(string)

  • Storage.getStream(path, res) StreamObject

Production

  • npm run build && npm run serve

TODO

  • Mailer Class
    • SMTP
    • SES
1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago