Coder Social home page Coder Social logo

elektropay / api-server-nodejs-pro Goto Github PK

View Code? Open in Web Editor NEW

This project forked from app-generator/api-server-nodejs-mongo

0.0 1.0 0.0 40 KB

Nodejs API Server - Express / SQLite / MongoDB | AppSeed

Home Page: https://appseed.us

License: Other

api-server-nodejs-pro's Introduction

Nodejs API Server PRO

Express / Nodejs Starter with JWT authentication, and SQLite or MongoDB persistance - Provided by AppSeed App Generator. Authentication flow uses json web tokens via Passport library - passport-jwt.


Features:

  • API Definition - the unified API structure implemented by this server
  • Simple, intuitive codebase - can be extended with ease.
  • Typescript
  • Data validation with Joy
  • Branches:
    • Master: NodeJS / Express / SQLite / TypeORM
    • Mongo: NodeJS / Express / MongoDB / Mongoose
  • Auth: Passport / passport-jwt strategy
  • Unitary tests, Docker

Free Version available: SQLite persistance, Unitary Tests, 24/7 LIVE Support via Discord

Can be used with other React Starters for a complete Full-Stack experience:

React Node JS Berry Full-Stack Material PRO React Node Datta Able
React Node JS Berry Full-Stack Material PRO React Node Datta Able

Nodejs API Server - Open-source Nodejs Starter provided by AppSeed.


Requirements


How to use the code

Step #1 - Clone the project (private repository)

$ git clone https://github.com/app-generator/priv-api-server-nodejs.git
$ cd priv-api-server-nodejs

Step #2 - Install dependencies via NPM or Yarn

$ npm i
// OR
$ yarn

Step #3 - Run the SQLite migration via TypeORM

$ 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 for production (files served from build/index.js)

$ 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

API

For a fast set up, use this POSTMAN file: api_sample

Register - api/users/register

POST api/users/signup
Content-Type: application/json

{
    "username":"test",
    "password":"pass", 
    "email":"[email protected]"
}

Login - api/users/login

POST /api/users/login
Content-Type: application/json

{
    "password":"pass", 
    "email":"[email protected]"
}

Logout - api/users/logout

POST api/users/logout
Content-Type: application/json
authorization: JWT_TOKEN (returned by Login request)

{
    "token":"JWT_TOKEN"
}

Credits

This software is provided by the core AppSeed team with an inspiration from other great NodeJS starters:



Nodejs API Server PRO - provided by AppSeed App Generator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.