-
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 dbdbd39
Showing
61 changed files
with
8,383 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,9 @@ | ||
|
||
AUTH_SECRET='*secret assortment of characters used for encryption*' | ||
PORT=*insert desired backend server port here* | ||
DATABASE_URL=mongodb+srv://... | ||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
S3_BUCKET_NAME= | ||
SENDGRID_EMAIL= | ||
SENDGRID_API_KEY= |
Empty file.
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,53 @@ | ||
{ | ||
"extends": [ | ||
"airbnb-typescript/base", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"env": { | ||
"browser": false, | ||
"node": true, | ||
"es6": true, | ||
"jest": true | ||
}, | ||
"rules": { | ||
"no-console": "off", | ||
"comma-dangle": "off", | ||
"linebreak-style": "off", | ||
"no-underscore-dangle": "off", | ||
"max-len": ["error", { "code": 200 }], | ||
"indent": ["error", 2, { "SwitchCase": 1 }], | ||
|
||
"import/extensions": "off", | ||
"import/prefer-default-export": "off", | ||
|
||
// Bugfix https://stackoverflow.com/questions/63961803/eslint-says-all-enums-in-typescript-app-are-already-declared-in-the-upper-scope | ||
"no-shadow": "off", | ||
"@typescript-eslint/no-shadow": ["error"], | ||
"@typescript-eslint/no-empty-interface": "off", | ||
"no-unused-vars": "off", | ||
|
||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/interface-name-prefix": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/ban-ts-ignore": "off" | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"node": { | ||
"moduleDirectory": [ | ||
"node_modules", | ||
"src/" | ||
], | ||
"extensions": [".js", ".ts"] | ||
} // this loads <rootdir>/tsconfig.json to eslint | ||
} | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"import" | ||
] | ||
} |
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,9 @@ | ||
# Description | ||
|
||
One to two sentence description. | ||
|
||
## Type of Issue | ||
|
||
- [ ] New feature | ||
- [ ] Bug fix | ||
- [ ] Documentation update |
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,23 @@ | ||
# Description | ||
|
||
One to two sentence description. | ||
|
||
## Type of Change | ||
|
||
- [ ] New feature | ||
- [ ] Bug fix | ||
- [ ] Breaking change | ||
- [ ] Documentation update | ||
|
||
## Checklist | ||
|
||
- [ ] Unit/integration tests | ||
- [ ] Documentation | ||
|
||
## Tickets | ||
|
||
- [Issue Number](Link) | ||
|
||
## Screenshots | ||
|
||
Please attach any design screenshots if UI update. |
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,8 @@ | ||
node_modules/ | ||
.vscode/ | ||
*.env | ||
globalConfig.json | ||
yarn-error.log | ||
dist | ||
coverage/ | ||
dist/ |
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,101 @@ | ||
# CRUD Template - Backend - Prisma | ||
|
||
This repository is an optional backend starter pack for new DALI React projects. Installation and setup instructions are included below. You should eventually customize this README file with project-specific documentation. | ||
|
||
## How To Extend This Template | ||
See the template repo's Wiki page. | ||
|
||
## Designs | ||
[Screenshot description] | ||
|
||
[Link to the project Figma]() | ||
|
||
[2-4 screenshots from the app] | ||
|
||
## Architecture | ||
### Tech Stack | ||
- [Express](https://expressjs.com/) | ||
- [Prisma ORM](https://www.prisma.io/) | ||
- [Passport.js](https://www.passportjs.org/) | ||
- [axios](https://github.com/axios/axios) | ||
- [TypeScript](https://www.typescriptlang.org/docs/) | ||
|
||
#### External Packages | ||
- [aws-sdk](https://yarnpkg.com/package/aws-sdk) | ||
- [@sendgrid/mail](https://docs.sendgrid.com/for-developers/sending-email/quickstart-nodejs) | ||
- [Add any other notable external packages here] | ||
|
||
### Style | ||
[Describe notable code style conventions] | ||
|
||
We are using [typically a configuration like [CS52's React-Native ESLint Configuration](https://gist.github.com/timofei7/c8df5cc69f44127afb48f5d1dffb6c84) or [CS52's ES6 and Node ESLint Configuration](https://gist.github.com/timofei7/21ac43d41e506429495c7368f0b40cc7)] | ||
|
||
### Data Models | ||
[Brief description of typical data models.] | ||
|
||
[Detailed description should be moved to the repo's Wiki page] | ||
|
||
### Directory Structure | ||
|
||
. | ||
├── ... | ||
├── src | ||
| └── auth # JWT middleware | ||
| └── controllers # dispatch input; output | ||
| └── db # Prisma database definitions | ||
| └── errors # internal error handling | ||
| └── routers # route url endpoint | ||
| └── __tests__ # test cases for routers | ||
| └── services # handles database queries and related functionality | ||
| └── __tests__ # test cases for services | ||
| └── util # util functions, usually used by services | ||
| └── validation # validates input w/ joi | ||
| └── server.ts # starting point of server | ||
|
||
For more detailed documentation on our file structure and specific functions in the code, feel free to check the project files themselves. | ||
|
||
## Setup | ||
|
||
For this setup, we will use MongoDB as the database Prisma operates upon. It should be relatively straightforward to use a different database (like Postgres) with the same code, if you so desire. | ||
|
||
1. Clone repo and `yarn install` | ||
2. Create [MongoDB Atlas database](https://www.mongodb.com/atlas/database) | ||
3. Set up SendGrid API (for email validation) | ||
- Information about SendGrid API keys: https://docs.sendgrid.com/ui/account-and-settings/api-keys | ||
4. Set up Amazon AWS s3 bucket (for photo storage) | ||
- https://brunchlabs.notion.site/ECSA-Uploading-images-to-S3-88be408bf5eb4aa987b7bea211258291 | ||
5. Create a `.env` file in the root directory, according to the format specified by `.env.example` | ||
6. Run `yarn prisma db seed` to apply seeding to DB. | ||
7. App should be ready for use now | ||
- `yarn start` to run in production mode | ||
- `yarn run dev` to run with hot reloading | ||
|
||
#### Linting | ||
|
||
ESLint is set up in this project. To keep code clean, always remember to run `yarn run lint` and fix any lint problems before merging into master. | ||
|
||
#### Unit / Integration Testing | ||
|
||
TBD | ||
|
||
## Deployment | ||
[Where is the app deployed? i.e. Expo, Surge, TestFlight etc.] | ||
|
||
[What are the steps to re-deploy the project with any new changes?] | ||
|
||
[How does one get access to the deployed project?] | ||
|
||
## Authors | ||
* Firstname Lastname 'YY, role | ||
|
||
## Acknowledgments | ||
We would like to thank [anyone you would like to acknowledge] for [what you would like to acknowledge them for]. | ||
|
||
--- | ||
Designed and developed by [@DALI Lab](https://github.com/dali-lab) | ||
|
||
### Template | ||
|
||
- Eric Lu '25 | ||
|
||
Additional credit goes to Adam McQuilkin '22, Ziray Hao '22, Jack Keane '22, Thomas Monfre '21 for developing the original DALI CRUD Template Backend, which this starter pack was evolved from. |
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,81 @@ | ||
{ | ||
"name": "crud-template-backend-mongodb", | ||
"version": "1.0.0", | ||
"description": "DALI Lab CRUD template w/ MongoDB", | ||
"productionURL": "https://your-api-url.here", | ||
"productionClientURL": "https://your-app-url.here", | ||
"main": "src/server.js", | ||
"repository": "https://github.com/dali-lab/crud-template-backend-mongodb", | ||
"author": "Eric Lu <[email protected]>", | ||
"contributors": [ | ||
"Adam McQuilkin <[email protected]>", | ||
"Alex Lopez <[email protected]>", | ||
"Ziray Hao <[email protected]>", | ||
"Jack Keane <[email protected]>" | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"lint": "eslint ./src", | ||
"dev": "nodemon -r tsconfig-paths/register src/server.ts --exec ts-node", | ||
"start": "NODE_OPTIONS=--max-old-space-size=8192 ts-node --transpile-only -r tsconfig-paths/register src/server.ts", | ||
"build": "yarn install && tsc", | ||
"prod": "yarn build dist; node dist/server.js" | ||
}, | ||
"prisma": { | ||
"seed": "ts-node src/db/seed.ts", | ||
"schema": "src/db/schema.prisma" | ||
}, | ||
"dependencies": { | ||
"@prisma/client": "^5.11.0", | ||
"@sendgrid/mail": "^7.7.0", | ||
"aws-sdk": "^2.1338.0", | ||
"axios": "^0.25.0", | ||
"bcrypt": "^5.0.1", | ||
"body-parser": "^1.19.1", | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.0.0", | ||
"email-validator": "^2.0.4", | ||
"env-var": "^7.1.1", | ||
"express": "^4.17.2", | ||
"express-joi-validation": "^5.0.1", | ||
"joi": "^17.6.0", | ||
"jwt-simple": "^0.5.6", | ||
"morgan": "^1.10.0", | ||
"passport": "^0.5.2", | ||
"passport-jwt": "^4.0.0", | ||
"passport-local": "^1.0.0", | ||
"sharp": "^0.31.3", | ||
"ts-node": "^10.5.0", | ||
"tsconfig-paths": "^3.12.0", | ||
"typescript": "^4.5.5" | ||
}, | ||
"devDependencies": { | ||
"@types/bcrypt": "^5.0.0", | ||
"@types/cors": "^2.8.12", | ||
"@types/express": "^4.17.13", | ||
"@types/jest": "^27.4.0", | ||
"@types/morgan": "^1.9.3", | ||
"@types/node": "^17.0.16", | ||
"@types/passport": "^1.0.7", | ||
"@types/passport-jwt": "^3.0.6", | ||
"@types/passport-local": "^1.0.34", | ||
"@types/supertest": "^2.0.11", | ||
"@types/uuid": "^8.3.4", | ||
"@typescript-eslint/eslint-plugin": "^5.11.0", | ||
"@typescript-eslint/parser": "^5.11.0", | ||
"debug": "^4.3.3", | ||
"eslint": "^8.8.0", | ||
"eslint-config-airbnb-typescript": "^16.1.0", | ||
"eslint-plugin-import": "^2.25.4", | ||
"jest": "^27.5.1", | ||
"jest-environment-node": "^27.5.1", | ||
"jest-mock-extended": "^3.0.5", | ||
"mockingoose": "^2.15.2", | ||
"mongodb-memory-server": "^8.3.0", | ||
"nodemon": "^2.0.15", | ||
"prisma": "^5.11.0", | ||
"supertest": "^6.2.2", | ||
"ts-jest": "^27.1.3", | ||
"uuid": "^9.0.0" | ||
} | ||
} |
Oops, something went wrong.