This is the backend of Snipcode, containing the business logics related to .
- Node.js
- TypeScript
- GraphQL
- MySQL
- Prisma
Make sure you have this tools installed before running the project
- Node.js 20+
- NPM or Yarn
- Docker
- AWS CLI v2
- MySQL 8 on PlanetScale
We use Yarn workspace to create packages we can share with other applications.
These packages are located in the folder packages
, so you might need to change the code of one or many packages to implement a feature.
Here are the packages used in this project:
Delete the existing folders output from build commands
yarn clean
Install node modules
yarn install
Create configuration file from the template
cp .env.template .env
# Edit configuration to match your local environment and save
nano .env
Environment variables list
Variable | Description |
---|---|
NODE_ENV | Node.js environment (default: development) |
HOST | Host name where the application is running (default: https://localhost) |
PORT | Port number of the application (default: 7501) |
ENABLE_INTROSPECTION | Enable/Disable GraphQL introspection (must false in production) |
DATABASE_URL | URL of the database |
ADMIN_PASSWORD | Password of the default admin user. |
CONVERTKIT_API_KEY | ConvertKit API key |
CONVERTKIT_FORM_ID | ConvertKit Form ID |
CONVERTKIT_TAG_ID | ConvertKit Tag ID |
REQUEST_TIMEOUT | Max duration of a request (default: 30 seconds) |
GITHUB_CLIENT_ID | GitHub application client ID for authentication with GitHub |
GITHUB_CLIENT_SECRET | GitHub application client secret for authentication with GitHub |
WEB_APP_URL | URL of the frontend the application that communicates with this app |
WEB_AUTH_SUCCESS_URL | Callback URL of the frontend application when the authentication succeed |
WEB_AUTH_ERROR_URL | Callback URL of the frontend application when the authentication failed |
SESSION_LIFETIME | The session's lifetime when a user authenticate (default: 90 days) |
SENTRY_DSN | Sentry DSN |
SENTRY_ENABLED | Enable/Disable Sentry |
Start the application
yarn dev
The application will be launched by Nodemon.
Open https://localhost:7501/graphql in your browser and use Apollo studio explorer to test your GraphQL queries and mutations.
Run the command below to run all the tests
yarn test
To run a specific test file, append the filename after the command
yarn test controller.test.ts
ESLint and Prettier are used to normalize the code style across the project. Linting the code make sure there is no error
yarn lint