tnema
TypeScript icon, indicating that this package has built-in type declarations

0.4.4 • Public • Published

TNEMA

Server Bundle with: TypeScript + Node + Express + MongoDB + Authentication

NPM

Work Progress:

  • Core functionalities: done
  • Http Server: done
  • MongoDB Server: done
  • Authentication Server: done
  • Security: in testing *

*Security: express-session is no longer used. Instead, was create a cookie/token logic to authenticate users. Clients should send tokenid every request to check authentication thru header (see test.js and test/ folder for example)

Requirements

# if you are running thru TypeScript, install it before:
npm install typescript

# also requires @types
npm install @types/body-parser @types/express @types/cookie-parser @types/mongoose

Also requires an instance of MongoDB running.

Install

# install TNEMA Server
npm install tnema --save

Usage

To start a server with static routing on './public':

  tnema = require('tnema');
  
  // create server instance with session-name and session-file  
  server = new tnema.TNEMAServer('sessionName','./appSessions.json');
  
  // define port
  server.Port = 3000;

  // define cookie maxage = days * hours * minutes * seconds * ms
  server.Options.maxAge = 30 * 24 * 60 * 60 * 1000;
  
  // define the source of mongodb
  server.MongoSource = 'mongodb://localhost/test';
  
  // add static route to public folder
  server.HttpServer.RouteStatic(__dirname + '/public');

  // add route to /test and send the content
  server.HttpServer.App.get('/test', (req, res) => {
      res.send('Test Sucessfully');
  });
  
  // start server
  server.Create(function(){
    console.log('Server started at port: 3000');
  });

License

MIT

Package Sidebar

Install

npm i tnema

Weekly Downloads

8

Version

0.4.4

License

MIT

Unpacked Size

166 kB

Total Files

35

Last publish

Collaborators

  • deberson.paula