@tiscode/node-base
v0.2.1
Published
TISCODE Base Module for NodeJS Applications
Downloads
10
Maintainers
Readme
TISCODE Node Base
Version: v0.2.1
- Hotfix cannot set headers after they are sent
Version: v0.2.0
- ExpressAuthenticatedHandler with jsonwebtoken
- ExpressPublicHandler
- Handlers must implement handle method
Version: v0.1.0
- HttpServer app with peer support for graphql
- Http Event Types
- Express adapter (for Handler constructor and Command Factory constructor)
- Express default handler and abstract handler
- Command and Command Factory abstracts
- iif helper function
- ifnull helper function
Installation
npm i @tiscode/node-base
or yarn add @tiscode/node-base
Usage
import { App } from '@tiscode/node-base';
import MyCommandFactory from './factories/commands/my-command';
const expressAuthenticatedHandler = App.Http.Express.adapter(App.Http.Express.authenticatedHandler, MyCommandFactory);
const app = new App.Http.Server();
app.on('started', () => {
app.attachRouter({
path: '/my-endpoint',
method: 'post', // you can change this to 'put', 'get', 'delete', 'patch' or 'all'
router: expressAuthenticatedHandler
});
});
app.listen(3000);
import { Router } from 'express';
import { App } from '@tiscode/node-base';
import MyCommandFactory from './factories/commands/my-command';
const expressAuthenticatedHandler = App.Http.Express.adapter(App.Http.Express.authenticatedHandler, MyCommandFactory);
const app = new App.Http.Server();
const router = Router();
router.post('/my-endpoint', expressAuthenticatedHandler);
app.on('started', () => {
app.attachRouter({
path: '/api', // default is '/'
method: 'use',
router: expressAuthenticatedHandler
});
});
app.listen(3000);
import express from 'express';
import { App } from '@tiscode/node-base';
import MyCommandFactory from './factories/commands/my-command';
const expressAuthenticatedHandler = App.Http.Express.adapter(App.Http.Express.authenticatedHandler, MyCommandFactory);
const app = express();
app.post('/my-endpoint', expressAuthenticatedHandler);
app.listen(3000);