API Server NodeJS
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.
Dec 2, 2022
- API Definition - the unified API structure implemented by this server
- Node JS API Server - source code
- Full-stack samples compatible with this product:
- React Berry Dashboard - open-source sample
- React Datta Dashboard - open-source sample
API Interface - 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
Tested with:
NodeJS | NPM | YARN |
---|---|---|
v18.0.0 | ✅ | ✅ |
v16.10.0 | ✅ | ✅ |
v14.15.0 | ✅ | ✅ |
How to use the code​
👉 Step 1 - Clone the sources
$ git clone https://github.com/app-generator/api-server-nodejs.git
$ cd api-server-nodejs
👉 Step 2 - Install dependencies via NPM or Yarn
$ npm i
// OR
$ yarn
👉 Step 3 - Run the
SQLite
migration
$ yarn typeorm migration:run
👉 Step 4 - Start the API server (development mode)
$ npm dev
// OR
$ yarn dev
👉 Step 5 - Production Build (files generated in
build
directory)
$ npm build
// OR
$ yarn build
👉 Step 6 - Start the API server (production mode)
$ npm start
// OR
$ yarn start
The API server will start using the PORT
specified in .env
file (default 5000)
Codebase Structure​
< ROOT / src >
|
|-- config/
| |-- config.ts # Configuration
| |-- passport.ts # Define Passport Strategy
|
|-- migration/
| |-- some_migration.ts # database migrations
|
|-- models/
| |-- activeSession.ts # Sessions Model (Typeorm)
| |-- user.ts # User Model (Typeorm)
|
|-- routes/
| |-- users.ts # Define Users API Routes
|
|
|-- index.js # API Entry Point
|-- .env # Specify the ENV variables
|
|-- ************************************************************************
SQLite Path​
The SQLite Path is set in .env
, as SQLITE_PATH
✨ Database migration​
👉
Generate
migration:
$ yarn typeorm migration:generate -n your_migration_name
👉
Run
migration:
$ yarn typeorm migration:run
Compatible Fullstack Products​
React Soft Dashboard​
React Soft Dashboard
is built with over 70 frontend individual elements, like buttons, inputs, navbars, nav tabs, cards, or alerts, giving you the freedom of choosing and combining.
The product comes with a simple JWT authentication flow: login/register/logout.
The React Design is crafted by Creative-Tim on top of MUI
Library.
React Purity Dashboard​
Start your Development with an Innovative Admin Template for Chakra UI and React.
- ✅ Innovative Chakra Design -
Designed
by Creative-Tim - ✅ React, Redux, Redux-persist
- ✅ Authentication: JWT Login/Register/Logout
Django React Berry​
Full-Stack
Seed project generated by React App Generator top of Berry Dashboard design.
- 👉 Django React Berry - product page
- 👉 Django React Berry - LIVE Demo
✅ Resources​
- 👉 Access AppSeed and start your next project
- 👉 Deploy Projects on Aws, Azure and Digital Ocean via DeployPRO
- 👉 Create an amazing landing page with Simpllo, an open-source site builder
- 👉 Django App Generator - A 2nd generation App Builder