@nexys/koa-lib
TypeScript icon, indicating that this package has built-in type declarations

3.0.11 • Public • Published

Nexys web framework

CI NPM package NPM package Bundleophobia Prettier

Nexys typescript web framework (built on top of Koa and Nexys System SDK)

to

Setup

App init

path suggestion: src/app.ts

import Mount from 'koa-mount';
import { App, Routes } from '@nexys/koa-lib';

// import module/service
import RouteModule from './route/module';

// reference to the instance of nexys-lib
import LibServices from "./service/product-service";

const app = App();
// reference to service/module:
app.use(Mount('/pathTorouteModule', RouteModule));

// this is the reference to the product route modules (i18n, notification, cms)
// [optional]
app.use(Mount("/product", Routes.default(LibServices as any)));


export const startApp = async (port: number) => {
  app.listen(port, () => console.log(`Server started at port ${port}`));
};

Cache Initialization

path suggestion: src/service/cache.ts

import { Cache } from '@nexys/koa-lib';
export default new Cache.Local({persistent: true });

Middleware Auth

path suggestion: src/middleware/auth.ts

import { Middleware} from '@nexys/koa-lib';
import * as Login from '../service/login';
import cache from '../service/cache';

// initalises the middleware auth with
// - `Profile` defines the JWT Profile shape
// - `UserCache` defines the shape of the information saved in the userCache
// - `cache`reference to the cache
export default new Middleware.Auth<Login.Profile, Login.UserCache>(cache);

Readme

Keywords

none

Package Sidebar

Install

npm i @nexys/koa-lib

Weekly Downloads

1

Version

3.0.11

License

MIT

Unpacked Size

453 kB

Total Files

224

Last publish

Collaborators

  • nexys