-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
17fc322
commit c621f86
Showing
62 changed files
with
22,135 additions
and
136 deletions.
There are no files selected for viewing
File renamed without changes
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
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ node_modules | |
.output | ||
.env | ||
dist | ||
coverage/** | ||
coverage | ||
|
||
# system-related | ||
.DS_Store |
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,89 +1,38 @@ | ||
 | ||
 | ||
|
||
[](https://github.com/makerdao-ses/switchboard-boilerplate/actions/workflows/ci.yaml) | ||
[](https://www.gnu.org/licenses/agpl-3.0) | ||
|
||
# Powerhouse Switchboard | ||
|
||
Open-source API over database models made to be developer- and analyst-friendly. | ||
Open-source API over the [document model](https://github.com/makerdao-ses/document-model-libs) made to be developer- and analyst-friendly. | ||
|
||
 | ||
|
||
## Development | ||
## Quick start | ||
|
||
We use TypeScript, JavaScript and Node 18 (LTS) to develop this project. Commands: | ||
```sh | ||
# Set the required environment variables | ||
cp .env.development .env | ||
1. Set up [required enviourment variables](./api/#environment-variables) for the API | ||
- Default values can be copied via `cp ./api/developer.env ./api/.env` | ||
2. Start the project via a single docker-compose command | ||
```sh | ||
docker-compose up --build --force-recreate | ||
``` | ||
3. Open [http://localhost](http://localhost) to view the frontend | ||
|
||
# Install all required dependencies | ||
npm i | ||
## Project structure | ||
- [`/api`](./api) directory contains the core logic that creates the API over the database | ||
- [`/frontend`](./frontend) directory contains the frontend-related code | ||
|
||
# Run application in development mode | ||
npm run dev | ||
Please navigate to the respective directories to read concrete instructions on how to start them separately and develop them further. | ||
|
||
# Run application with extensive logging enabled (full ORM logging + app's logger has `debug` level on) | ||
npm run debug | ||
## Project requirements | ||
|
||
# Typechecking (via TypeScript / tsc) | ||
npm run typecheck | ||
|
||
# Linting (via eslint) | ||
npm run lint | ||
|
||
# Testing via vitest | ||
npm run test | ||
``` | ||
|
||
### Logging configuration | ||
|
||
The configuration is received from the `logger.config.ts` file at the root of the project. Adjust the file parameters to control the logger behaviour. | ||
|
||
### Coding Setup | ||
|
||
To install the correct node version, we recommend that you use [nvm](https://github.com/nvm-sh/nvm). If you have `nvm` installed you can run: | ||
```sh | ||
nvm install | ||
nvm use | ||
``` | ||
to automatically use the correct node version. The version is detected from the [.nvmrc](./.nvmrc). | ||
|
||
If you do not have a code editor setup, we recommend that you use [Visual Studio Code](https://code.visualstudio.com/) to get started. It is very beginner friendly and you can move on to something else (such as Sublime, vim, emacs, ...) down the road if you want to. | ||
|
||
Some environment variables are pre-configured for the development. You can copy them over to your `.env` file by running: | ||
|
||
```sh | ||
cp developer.env .env | ||
``` | ||
|
||
### Environment variables | ||
|
||
- `DATABASE_URL` (required): path to the database file. | ||
- `JWT_SECRET` (required): server's jwt secret. | ||
- `PORT` (optional, default: 3000): port on which the server will run. | ||
- `AUTH_SIGNUP_ENABLED` (optional, default: `false`): if signing up mutation is allowed (i.e. user creation via endpoint is enabled) | ||
- `JWT_EXPIRATION_PERIOD` (optional, default: `'7d'`): how soon the signed jwt token will expire. | ||
- `DEBUG` (optional): if set, enables the different more explicit logging mode where debug levels are set to `debug` for the app's logger and `query` for db logger | ||
|
||
### Project-Requirements | ||
|
||
To understand bettwe that is planned, you can read and ask questions here: | ||
To understand what is planned you can read and ask questions here: | ||
- Initial Requirements: https://github.com/makerdao-ses/switchboard-boilerplate/issues/3 | ||
- Document Model explanation: https://github.com/makerdao-ses/switchboard-boilerplate/issues/1 | ||
|
||
This covers the current idea of what we strive to achieve in a first phase. | ||
|
||
|
||
## Database | ||
|
||
We use [Prisma ORM](prisma.io/) as an ORM for this project. It is installed when you run `npm i`. Here are some useful commands for development: | ||
```sh | ||
# Push the current database schema to the database. This will also automatically generate the prisma client | ||
npx prisma db push | ||
## Coding Setup | ||
|
||
# Create the typescript database client from the `schema.prisma` file | ||
npx prisma generate | ||
To install correct node version, we recommend that you use [nvm](https://github.com/nvm-sh/nvm). If you have `nvm` installed you can run `nvm install && nvm use` to automatically use the correct node version. The version is detected from the [.nvmrc](./.nvmrc). | ||
|
||
# Get a live-view of the database, useful for development and testing | ||
npx prisma studio | ||
``` | ||
If you do not have a code editor setup, we recommend that you use [Visual Studio Code](https://code.visualstudio.com/) to get started. It is very beginner friendly and you can move on to something else down the road if you want to. |
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,6 @@ | ||
node_modules | ||
npm-debug* | ||
.nuxt | ||
dist | ||
tests | ||
.output |
File renamed without changes.
File renamed without changes.
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 @@ | ||
# see https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact | ||
ARG NODE_VERSION=node:16.14.2 | ||
|
||
FROM $NODE_VERSION AS dependency-base | ||
|
||
# create destination directory | ||
RUN mkdir -p /app | ||
WORKDIR /app | ||
|
||
# copy the app, note .dockerignore | ||
COPY package.json . | ||
COPY package-lock.json . | ||
RUN npm ci | ||
|
||
FROM dependency-base AS production | ||
|
||
COPY . . | ||
|
||
# Run in production mode | ||
ENV NODE_ENV=production | ||
|
||
# start the app | ||
CMD [ "npm", "run", "start" ] |
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,55 @@ | ||
# Switchboard API | ||
|
||
The core of the system that wraps around the [business logic](https://github.com/makerdao-ses/document-model-libs) developed in a separate repository. | ||
|
||
## Development | ||
|
||
We use TypeScript and Node 18 (LTS) to develop this project. Commands: | ||
```sh | ||
# Set the required environment variables | ||
cp .env.development .env | ||
|
||
# Install all required dependencies | ||
npm i | ||
|
||
# Run application in development mode | ||
npm run dev | ||
|
||
# Typechecking (via TypeScript / tsc) | ||
npm run typecheck | ||
|
||
# Linting (via eslint) | ||
npm run lint | ||
|
||
# Testing via vitest | ||
npm run test | ||
``` | ||
|
||
### Environment variables | ||
|
||
Some environment variables are pre-configured for the development. You can copy them over to your `.env` file by running `cp developer.env .env` | ||
|
||
- `DATABASE_URL` (required): path to the database file | ||
- `JWT_SECRET` (required): server's jwt secret | ||
- `PORT` (optional, default: 3000): port on which the server will run | ||
- `AUTH_SIGNUP_ENABLED` (optional, default: `false`): if signing up mutation is allowed (i.e. user creation via endpoint is enabled) | ||
- `JWT_EXPIRATION_PERIOD` (optional, default: `'7d'`): how soon the signed jwt token will expire | ||
- `DEBUG` (optional): if set, enables the different more explicit logging mode where debug levels are set to `debug` for the app's logger and `query` for db logger | ||
|
||
### Database | ||
|
||
We use [Prisma ORM](prisma.io/) as an ORM for this project. It is installed when you run `npm i`. Here are some useful commands for development: | ||
```sh | ||
# Push the current database schema to the database. This will also automatically generate the prisma client | ||
npx prisma db push | ||
|
||
# Create the typescript database client from the `schema.prisma` file | ||
npx prisma generate | ||
|
||
# Get a live-view of the database, useful for development and testing | ||
npx prisma studio | ||
``` | ||
|
||
### Logging configuration | ||
|
||
The configuration is received from the `logger.config.ts` file at the root of the project. Adjust the file parameters to control the logger behaviour. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,16 @@ | ||
import { defineConfig, UserConfig } from 'vitest/config'; | ||
|
||
export const defaultConfig: UserConfig = { | ||
test: { | ||
coverage: { | ||
enabled: true, | ||
provider: 'istanbul', | ||
lines: 90, | ||
functions: 90, | ||
statements: 90, | ||
}, | ||
singleThread: true, | ||
}, | ||
}; | ||
|
||
export default defineConfig(defaultConfig); |
Oops, something went wrong.