-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d9117c7
Showing
115 changed files
with
10,816 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# write postman link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/node_modules | ||
/dist | ||
.dockerignore | ||
Dockerfile | ||
*.md | ||
.pnpm-debug.log | ||
/uploads | ||
|
||
# .envs | ||
.env | ||
# .env.prod and account json for firebase should be allowed to copy into container otherwise how it will run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# if you update this file, update .env.example and .env.config.ts | ||
NODE_ENV=development | ||
# test, development, production | ||
|
||
PORT=4000 | ||
TZ=Etc/UTC | ||
|
||
# database | ||
DATABASE_URL="mysql://root:myPassWord@localhost:3308/mm_db" # mm_db, test | ||
|
||
# redis | ||
REDIS_URL="redis://default:1234567@localhost:6379" | ||
# redis cluster (not used) | ||
REDIS_CLUSTER_ENABLE='false' | ||
REDIS_CLUSTER_URLS="one,two,three" | ||
REDIS_CLUSTER_PORT="6379" | ||
|
||
# access token | ||
ACCESS_TOKEN_VALIDITY=7 # in days | ||
|
||
# enable socket | ||
ENABLE_SOCKET='false' | ||
|
||
# logger | ||
LOKI_HOST="https://xxxxx.grafana.net" | ||
LOKI_AUTH="xxxxxxxxxxxxxxxxxxxxxxxxx" | ||
|
||
# SMTP Mail | ||
SMTP_HOST="smtp-relay.xxxx.com" | ||
SMTP_PORT=587 | ||
SMTP_USER="[email protected]" | ||
SMTP_PASSWORD="xxxxxxx" | ||
SMTP_EMAIL_FROM="NestPress <[email protected]>" | ||
|
||
# google login | ||
G_WEB_CLIENT_ID="XXXXX-XXXXX.apps.googleusercontent.com" | ||
G_ANDROID_CLIENT_ID="XXXXX-XXXXX.apps.googleusercontent.com" | ||
G_IOS_CLIENT_ID="XXXXX-XXXXX.apps.googleusercontent.com" # not used | ||
G_SECRET_ID="XXX-XXXXX" # not used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# if you update this file, update .env.example and .env.config.ts | ||
NODE_ENV=production | ||
# test, development, production | ||
|
||
PORT=4000 | ||
TZ=Etc/UTC | ||
|
||
# database | ||
DATABASE_URL="mysql://root:myPassWord@localhost:3308/mm_db" # mm_db, test | ||
|
||
# redis | ||
REDIS_URL="redis://default:1234567@localhost:6379" | ||
# redis cluster (not used) | ||
REDIS_CLUSTER_ENABLE='false' | ||
REDIS_CLUSTER_URLS="one,two,three" | ||
REDIS_CLUSTER_PORT="6379" | ||
|
||
# access token | ||
ACCESS_TOKEN_VALIDITY=7 # in days | ||
|
||
# enable socket | ||
ENABLE_SOCKET='false' | ||
|
||
# logger | ||
LOKI_HOST="https://xxxxx.grafana.net" | ||
LOKI_AUTH="xxxxxxxxxxxxxxxxxxxxxxxxx" | ||
|
||
# SMTP Mail | ||
SMTP_HOST="smtp-relay.xxxx.com" | ||
SMTP_PORT=587 | ||
SMTP_USER="[email protected]" | ||
SMTP_PASSWORD="xxxxxxx" | ||
SMTP_EMAIL_FROM="NestPress <[email protected]>" | ||
|
||
# google login | ||
G_WEB_CLIENT_ID="XXXXX-XXXXX.apps.googleusercontent.com" | ||
G_ANDROID_CLIENT_ID="XXXXX-XXXXX.apps.googleusercontent.com" | ||
G_IOS_CLIENT_ID="XXXXX-XXXXX.apps.googleusercontent.com" # not used | ||
G_SECRET_ID="XXX-XXXXX" # not used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
es2021: true, | ||
}, | ||
extends: [ | ||
"airbnb-base", | ||
"airbnb-typescript/base", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended", | ||
], | ||
overrides: [], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
project: "./tsconfig.json", | ||
}, | ||
plugins: ["@typescript-eslint", "prettier"], | ||
ignorePatterns: ["node_modules", "resources", "dist", "drizzle.config.ts", "vitest.config.ts"], | ||
rules: { | ||
"prettier/prettier": [ | ||
"warn", | ||
{ | ||
endOfLine: "auto", | ||
}, | ||
], | ||
"no-console": "warn", | ||
"linebreak-style": "off", | ||
"no-nested-ternary": "off", | ||
radix: "off", | ||
"no-underscore-dangle": "off", | ||
"import/prefer-default-export": "off", | ||
"class-methods-use-this": "off", | ||
"@typescript-eslint/dot-notation": "off", | ||
"require-await": ["error"], | ||
"@typescript-eslint/no-floating-promises": ["error"], | ||
"no-await-in-loop": ["off"], | ||
"import/no-cycle": "warn", | ||
"no-restricted-syntax": "off", | ||
}, | ||
} | ||
|
||
// if you change any rule then reload the window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
node_modules | ||
dist | ||
.env | ||
|
||
|
||
# few git ignore which we may include | ||
# .env.dev | ||
# .env.test | ||
# .env.staging | ||
# .env.prod | ||
account-key.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
# Increment the version number without creating a new commit and tag | ||
npm run version:inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
# it will thorw error and stop commit if there is any linting error, it will ignore warning | ||
npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// prettier.config.js or .prettierrc.js | ||
module.exports = { | ||
trailingComma: "es5", | ||
tabWidth: 4, | ||
printWidth: 115, | ||
semi: false, | ||
singleQuote: false, | ||
ignore: ["**/*.md", "!/*.md"], | ||
} | ||
|
||
// if you change any rule then reload the window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
{ | ||
// todo: https://snippet-generator.app/ | ||
"Test": { | ||
"prefix": "test-whatever", | ||
"body": ["$1 -> ${1/(.*)/${1:/capitalize}/}"], | ||
"description": "test output to console" | ||
}, | ||
"Nestpress Router": { | ||
"prefix": "npr", | ||
"body": [ | ||
"import { Router } from \"express\";", | ||
"import { $1Controller } from \"./${1/(.*)/${1:/downcase}/}.controller\";", | ||
"", | ||
"const $1Router = Router()", | ||
"", | ||
"/**", | ||
" * @description get all ${1/(.*)/${1:/downcase}/} with paginate", | ||
" * @url {{BASE_URL}}/${1/(.*)/${1:/downcase}/}/", | ||
" */", | ||
"$1Router.get('/', $1Controller.getAllByPaginate)", | ||
"", | ||
"/**", | ||
" * @description get single ${1/(.*)/${1:/downcase}/}", | ||
" * @url {{BASE_URL}}/${1/(.*)/${1:/downcase}/}/:id", | ||
" */", | ||
"$1Router.get('/:id', $1Controller.getSingle$1)", | ||
"", | ||
"/**", | ||
" * @description create a new ${1/(.*)/${1:/downcase}/}", | ||
" * @url {{BASE_URL}}/${1/(.*)/${1:/downcase}/}/", | ||
" */", | ||
"$1Router.post('/', $1Controller.create$1)", | ||
"", | ||
"/**", | ||
" * @description update a ${1/(.*)/${1:/downcase}/}", | ||
" * @url {{BASE_URL}}/${1/(.*)/${1:/downcase}/}/:id", | ||
" */", | ||
"$1Router.put('/:id', $1Controller.update$1)", | ||
"", | ||
"/**", | ||
" * @description delete a ${1/(.*)/${1:/downcase}/}", | ||
" * @url {{BASE_URL}}/${1/(.*)/${1:/downcase}/}/:id", | ||
" */", | ||
"$1Router.delete('/:id', $1Controller.delete$1)", | ||
"", | ||
"", | ||
"export default $1Router" | ||
], | ||
"description": "Nestpress Router" | ||
}, | ||
"Nestpress Controller": { | ||
"prefix": "npc", | ||
"body": [ | ||
"import { Request, Response, NextFunction } from \"express\"", | ||
"", | ||
"export const $1Controller = {", | ||
" getAllByPaginate: (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" return res.status(StatusCode.OK).json(MyResponse(\"operation successful\", true));", | ||
" } catch (e) {", | ||
" return next(e);", | ||
" }", | ||
" },", | ||
" getSingle$1: (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" return res.status(StatusCode.OK).json(MyResponse(\"operation successful\", true));", | ||
" } catch (e) {", | ||
" return next(e);", | ||
" }", | ||
" },", | ||
" create$1: (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" return res.status(StatusCode.OK).json(MyResponse(\"operation successful\", true));", | ||
" } catch (e) {", | ||
" return next(e);", | ||
" }", | ||
" },", | ||
" update$1: (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" return res.status(StatusCode.OK).json(MyResponse(\"operation successful\", true));", | ||
" } catch (e) {", | ||
" return next(e);", | ||
" }", | ||
" },", | ||
" delete$1: (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" return res.status(StatusCode.OK).json(MyResponse(\"operation successful\", true));", | ||
" } catch (e) {", | ||
" return next(e);", | ||
" }", | ||
" },", | ||
"}", | ||
"" | ||
], | ||
"description": "Express Controller" | ||
}, | ||
"update-me-later-based-on-project": { | ||
"prefix": "xxxxxxxx", | ||
"body": [ | ||
"import { $1 } from \"@prisma/client\"", | ||
"import { Request, Response, NextFunction } from \"express\"", | ||
"import { $1Dto } from \"../models/dto/$1Dto\"", | ||
"import { MyResponse } from \"../models/MyResponse\"", | ||
"import Constant from \"../utils/Constant\"", | ||
"import Helper from \"../utils/Helper\"", | ||
"", | ||
"const $1Controller = {", | ||
" getAllByPaginate: async (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" const page = req.query.page as string || \"1\"", | ||
" const page_size = req.query.page_size as string || Constant.PAGE_SIZE.toString()", | ||
" const skip = (parseInt(page) - 1) * parseInt(page_size)", | ||
" ", | ||
" if (isNaN(skip)) {", | ||
" throw new Error(\"Enter Valid Page Number and Page Size!\")", | ||
" }", | ||
" const count = await req.prisma.${1/(.*)/${1:/downcase}/}.count()", | ||
" const list = await req.prisma.${1/(.*)/${1:/downcase}/}.findMany({", | ||
" skip: skip,", | ||
" take: parseInt(page_size),", | ||
" orderBy: {", | ||
" createdAt: \"desc\"", | ||
" }", | ||
" })", | ||
" res.status(200).json(MyResponse<$1[]>(false, \"get data successfuly\", list,count))", | ||
" } catch (e) {", | ||
" console.log(\"getAllByPaginate: \", e)", | ||
" return next(e)", | ||
" }", | ||
" },", | ||
" getSingle$1: async (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" const { id } = req.params", | ||
"", | ||
" const ${1/(.*)/${1:/downcase}/} = await req.prisma.${1/(.*)/${1:/downcase}/}.findUnique({", | ||
" where: {", | ||
" id: id", | ||
" }", | ||
" })", | ||
" if (!${1/(.*)/${1:/downcase}/}) {", | ||
" throw new Error(\"No $1 Found!\")", | ||
" }", | ||
" res.status(200).json(MyResponse<$1>(false, \"get data successfuly\", ${1/(.*)/${1:/downcase}/}))", | ||
" } catch (e) {", | ||
" console.log(\"getSingle$1: \", e)", | ||
" return next(e)", | ||
" }", | ||
" },", | ||
" create$1: async (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" const { title, desc } = req.body as $1Dto", | ||
" const ${1/(.*)/${1:/downcase}/} = await req.prisma.${1/(.*)/${1:/downcase}/}.create({", | ||
" data: {", | ||
" title, desc", | ||
" }", | ||
" })", | ||
" res.status(200).json(MyResponse<$1>(false, \"created successfuly\", ${1/(.*)/${1:/downcase}/}))", | ||
" } catch (e) {", | ||
" console.log(\"create$1: \", e)", | ||
" return next(e)", | ||
" }", | ||
" },", | ||
" update$1: async (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" const { id } = req.params", | ||
" const { title, desc } = req.body as Partial<$1Dto>", | ||
" const ${1/(.*)/${1:/downcase}/} = await req.prisma.${1/(.*)/${1:/downcase}/}.update({", | ||
" data: {", | ||
" title: title || undefined,", | ||
" desc: desc || undefined", | ||
" },", | ||
" where: {", | ||
" id: id", | ||
" }", | ||
" })", | ||
" res.status(200).json(MyResponse<$1>(false, \"updated successfuly\", ${1/(.*)/${1:/downcase}/}))", | ||
" } catch (e) {", | ||
" console.log(\"update$1: \", e)", | ||
" return next(e)", | ||
" }", | ||
" },", | ||
" delete$1: async (req: Request, res: Response, next: NextFunction) => {", | ||
" try {", | ||
" const { id } = req.params", | ||
" const ${1/(.*)/${1:/downcase}/} = await req.prisma.${1/(.*)/${1:/downcase}/}.delete({", | ||
" where: {", | ||
" id: id", | ||
" }", | ||
" })", | ||
" res.status(200).json(MyResponse<$1>(false, \"deleted successfuly\", ${1/(.*)/${1:/downcase}/}))", | ||
" } catch (e) {", | ||
" console.log(\"delete$1: \", e)", | ||
" return next(e)", | ||
" }", | ||
" },", | ||
"}", | ||
"export $1Controller" | ||
], | ||
"description": "ExpressControoler" | ||
} | ||
} |
Oops, something went wrong.