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)
import { Router } from '@kernode/core'
import WebController from 'Controller/Http/WebController'
Router.get('/', WebController.index)
Socket
import { SocketListener } from '@kernode/core'
import WebSocketController from 'Controller/Ws/WebSocketController'
SocketListener.on('message', WebSocketController.onMessage)
Event Emitter
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
Jwt Auth
Storage (support Local and AWS S3)
Production
npm run build && npm run serve
TODO