Skip to content

Commit

Permalink
Merge pull request #25 from Mizety/master
Browse files Browse the repository at this point in the history
 Refactor Template: Role-Based User Management and Authentication
  • Loading branch information
Mayank-Tripathi32 authored Aug 18, 2024
2 parents 214e899 + 86954f5 commit da025c8
Show file tree
Hide file tree
Showing 52 changed files with 2,611 additions and 3,297 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ data/
jspm_packages/
audit.*
docker/*
src/*
errors.log.*
# TypeScript v1 declaration files
typings/
Expand All @@ -17,4 +16,9 @@ typings/
*.tsbuildinfo

# Optional npm cache directory
.npm
.npm

access.log

src/access.log
/src/access.log
5 changes: 0 additions & 5 deletions .idea/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/Rest Api.iml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

11 changes: 0 additions & 11 deletions .vscode/launch.json

This file was deleted.

35 changes: 0 additions & 35 deletions .vscode/tasks.json

This file was deleted.

15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Express API Starter
# Express Prisma Starter Template

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensrc.org/licenses/Apache-2.0)

How to use this template:
<img src="https://github.com/Leave-it-blank/Express-Starter-with-TS/blob/master/documentation/images/howtouse.jpg"/>

Includes API Server utilities:
Includes API index utilities:

- [Prisma](https://www.npmjs.com/package/prisma)
- ORM for Mysql schema generation and manupulation
- [Cron](https://www.npmjs.com/package/node-cron)
- For Sheduling the jobs to run.
- [Redis](https://www.npmjs.com/package/redis)
- Caching solution for jwt refresh token
- [Mysql](https://www.npmjs.com/package/morgan)
- Database for storing data.
- [morgan](https://www.npmjs.com/package/morgan)
Expand All @@ -32,15 +30,18 @@ Development utilities:
- ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.
- [Typescript](https://www.npmjs.com/package/typescript)
- For Tightly typing the codebase.
- [Docker](https://www.npmjs.com/package/docker)
- Dockerize the whole application


## Work in progress

- [jest](https://www.npmjs.com/package/jest)
- Jest is a delightful JavaScript Testing Framework with a focus on simplicity.
- [supertest](https://www.npmjs.com/package/supertest)
- HTTP assertions made easy via superagent.
- [Docker](https://www.npmjs.com/package/docker)
- Dockerize the whole application
- [cors](https://www.npmjs.com/package/cors)
- Add cron job for cleaning up blacklisted tokens every 2 days.

## Setup

Expand All @@ -62,13 +63,13 @@ npm run dev

## Project layout

The code for the microservice is contained in the `source` directory. All of the test are in the `tests` folder(wip). The code follows the **Model-View-Controller** pattern with all of the database code and business logic in the controler dir, and all of the RESTful routing (`routes`) Dir which supports sub folder routing.
The code for the microservice is contained in the `src` directory. All of the test are in the `tests` folder(wip). The code follows the **Model-View-Controller** pattern with all of the database code and business logic in the controler dir, and all of the RESTful routing (`routes`) Dir which supports sub folder routing.

```text
├── documentation <- template documentation files
├── source <- microservice template
├── src <- microservice template
│   ├── controllers/ <- application controllers for routes <- microservice
│   ├── server.ts <- express configuration file
│   ├── index.ts <- express configuration file
│   ├── tests/ <- code for the testing various apis //wip
│   └── routes/ <- code for the REST API routes
├── tsconfig.json <- ts setup config
Expand All @@ -89,16 +90,14 @@ The User model contains the following fields:
| username | String(64) | False |
| email | String(64) | False |
| password | String(32) | False |
| api_key | String(32) | False |
| role | enum(role) | False |
| created_at | DateTime | auto |
| updated_at | DateTime | auto |
| deleted_at | DateTime | auto |

Role Enum
| Name | Optional |
| ---------- | -------- |
| USER | default |
| Subscriber | default |
| ADMIN | False |
| MANAGER | False |
#Note
Expand All @@ -111,6 +110,10 @@ After updating database tables (ORM)

[Leave it Blank](https://github.com/Leave-it-blank/)

## Contributors

[Mizety](https://github.com/Mizety)

## License

Licensed under the Apache License. See [LICENSE](LICENSE)
26 changes: 0 additions & 26 deletions audit.json

This file was deleted.

14 changes: 0 additions & 14 deletions docker-compose.debug.yml

This file was deleted.

80 changes: 0 additions & 80 deletions docker-compose.yml

This file was deleted.

49 changes: 49 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ["**/node_modules/", "**/dist/"],
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
),
{
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
globals: {
...Object.fromEntries(
Object.entries(globals.browser).map(([key]) => [key, "off"])
),
...globals.node,
},

parser: tsParser,
ecmaVersion: "latest",
sourceType: "module",
},

rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/explicit-function-return-type": "off",
},
},
];
Loading

0 comments on commit da025c8

Please sign in to comment.