This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
Installation is done using the npm install
command:
---------Please note------------ Before using this module make sure you have installed phpmyadmin or any other mysql database in your local machine. ( xampp, wamp...etc ) -----------------------------------
- clone git repo using following command
- goto project directory:
cd node-auth
- Install the npm packages:
$ npm install
Before starting project setup your database configuration in .env file ( root directory)
DB_TYPE= DBMS (mysql, sqllite, mongodb, etc) DB_HOST=localhost DB_USER=root DB_PASS='secret' DB_NAME=test
Start the server in debug mode :
$ npm dev
Start the server: without debuging mode
$ npm devi
View the website at: http://localhost:3000/login
Host | Method | RoutePath | Middeware | Action |
---|---|---|---|---|
localhost:8000 | GET | "/index" |
checkJwt | Index View |
localhost:8000 | GET | "/login" |
isLogged | Login View |
localhost:8000 | POST | "/login" |
loginAuth | redirected to IndexPage |
localhost:8000 | GET | "/logout" |
null | null |
localhost:8000 | GET | "/api/teachers/" |
checkJwt | Get AllTeachers |
localhost:8000 | GET | "/api/teachers/{:id}" |
checkJwt | Get OneTeacher |
localhost:8000 | POST | "/api/teachers/" |
checkJwt | Create Teacher |
localhost:8000 | PATCH | "/api/teachers/{:id}" |
checkJwt | Update Teacher |
localhost:8000 | DELETE | "/api/teachers/{:id}" |
checkJwt | Destroy Teacher |
- Robust routing
- Focus on high performance
- HTTP helpers (redirection, cookies, etc)
- View system supported
- Executable for generating applications quickly
- supports both DataMapper and ActiveRecord (your choice)
- entities and columns
- database-specific column types
- entity manager
- repositories and custom repositories
- clean object relational model
- associations (relations)
- supports MySQL / MariaDB / Postgres / CockroachDB / SQLite / Microsoft SQL Server / Oracle / sql.js
- supports MongoDB NoSQL database
- TypeScript and JavaScript support
- follows all possible best practices
ProjectRoot
├── src // place of your TypeScript code
│ ├── entity // place where your entities (database models) are stored
│ │ └── User.ts // sample entity
│ ├── controllers // place where your controllers are stored
│ │ └── teacherController.ts // API Controller ( Teacher Entity )
│ │ └── authController.ts // Auth methods (Login, Logout)
│ ├── middlewares // place where your middlewares are stored
│ │ └── checkJwt.ts // for Sending/Receiving JWT Tokens via Cookies ( is Tokens are valides or not)
│ ├── routes // place where your API Routes are Defined
│ │ └── indexRoutes.ts // Routes except API
│ │ └── teacherRoutes.ts // Teacher API Routes
│ ├── views // Pug Files (Html Template, Front-end Views)
├── .gitignore // standard gitignore file
├── ormconfig.json // ORM and database connection configuration
├── package.json // node module dependencies
├── README.md // simple readme file
└── tsconfig.json // TypeScript compiler options
└── .ENV // server Configration, environment variables like Database Config, PORT, JWT Secrect Key, BASE_URL etc
Pstrikethrough textrodution Dependencies
-
@types/bcryptjs: "^2.4.2",
-
@types/body-parser: "^1.17.1",
-
@types/dotenv: "^6.1.1",
-
@types/helmet: "0.0.43",
-
@types/jsonwebtoken: "^8.3.3",
-
bcryptjs: "^2.4.3",
-
body-parser: "^1.19.0",
-
class-validator: "^0.10.0",
-
cookie-parser: "^1.4.4",
-
dotenv: "^8.1.0",
-
express: "^4.17.1",
-
helmet: "^3.20.0",
-
jsonwebtoken: "^8.5.1",
-
mysql2: "^1.6.5",
-
pug: "^2.0.4",
-
reflect-metadata: "^0.1.13",
-
ts-node-dev: "^1.0.0-pre.41",
-
typeorm: "^0.2.18",
-
typescript: "^3.5.3"
Dev Dependencies
- nodemon: "^1.19.1"