API Server Node JS
Open-source Node JS API Server enhanced with JWT Authentication and SQLite storage.
Free API Server coded on top of Express / Node JS with SQLite persistence and JWT authentication via Passport library - passport-jwt strategy.
Product Links
API Methods - for full description please access API Unified Definition​
    USERS API:
      /api/users/register: create a new user
      /api/users/login: authenticate an existing user
      /api/users/logout: delete the associated JWT token
      /api/users/checkSession: check an existing JWT Token for validity
      /api/users/edit - edit the information associated with a registered user
Node JS API Server - Open-source Product.
​

Requirements

​

How to use the code

Step #1 - Clone the sources
1
$ git clone https://github.com/app-generator/api-server-nodejs.git
2
$ cd api-server-nodejs
Copied!
Install dependencies via NPM or Yarn
1
$ npm i
2
// OR
3
$ yarn
Copied!
Run the SQLite migration
1
$ yarn typeorm migration:run
Copied!
Start the API server - development mode
1
$ npm dev
2
// OR
3
$ yarn dev
Copied!
Production Build - files generated in build directory
1
$ npm build
2
// OR
3
$ yarn build
Copied!
Start the API server - for production (files served from build/index.js)
1
$ npm start
2
// OR
3
$ yarn start
Copied!
The API server will start using the PORT specified in .env file (default 5000)

Codebase Structure

1
< ROOT / src >
2
|
3
|-- config/
4
| |-- config.ts # Configuration
5
| |-- passport.ts # Define Passport Strategy
6
|
7
|-- migration/
8
| |-- some_migration.ts # database migrations
9
|
10
|-- models/
11
| |-- activeSession.ts # Sessions Model (Typeorm)
12
| |-- user.ts # User Model (Typeorm)
13
|
14
|-- routes/
15
| |-- users.ts # Define Users API Routes
16
|
17
|
18
|-- index.js # API Entry Point
19
|-- .env # Specify the ENV variables
20
|
21
|-- ************************************************************************
Copied!

SQLite Path

The SQLite Path is set in .env, as SQLITE_PATH

Database migration

Generate migration:
1
$ yarn typeorm migration:generate -n your_migration_name
Copied!
run migration:
1
$ yarn typeorm migration:run
Copied!
​

Compatible Fullstack Products

The product can be used as a standalone server but also as an authentication server for React, Vue products. Such a product already configured with Django API Server is React Datta Able, an open-source React Dashboard.
React Datta Able - Open-Source Dashboard.
Last modified 2mo ago