Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit 8f083fb

Browse files
authored
Merge pull request #19 from IIM-Creative-Technology/dev
Release v0.1
2 parents c5eac13 + f3ce06a commit 8f083fb

30 files changed

Lines changed: 17865 additions & 10044 deletions

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
# Database:
3+
DB_NAME=name
4+
DB_USER=user
5+
DB_PASSWORD=password
6+
7+
DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@localhost:5432/${DB_NAME}?schema=public"

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'PR check'
2+
on: pull_request
3+
jobs:
4+
build-and-test:
5+
name: 'Build and test project'
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- name: 'Use Node.js LTS'
10+
uses: actions/setup-node@v2
11+
with:
12+
node-version: lts/*
13+
- name: 'Cache node modules'
14+
uses: actions/cache@v2
15+
env:
16+
cache-name: cache-node-modules
17+
with:
18+
path: ~/.npm
19+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
20+
restore-keys: |
21+
${{ runner.os }}-build-${{ env.cache-name }}-
22+
${{ runner.os }}-build-
23+
${{ runner.os }}-
24+
- name: 'Install dependencies'
25+
run: npm ci --prefer-offline
26+
- name: 'Build project'
27+
run: npm run build
28+
- name: 'Run tests'
29+
run: npm run test
30+
- name: 'Lint project code'
31+
run: npm run lint

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ node_modules
88
# testing
99
coverage
1010

11-
# next.js
12-
.next/
13-
out/
14-
build
11+
# ESLint
12+
.eslintcache
1513

1614
# misc
1715
.DS_Store
@@ -32,3 +30,6 @@ yarn-error.log*
3230

3331
# turbo
3432
.turbo
33+
34+
# editor
35+
.idea

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This repository is a monorepo powered by [Turborepo](https://turborepo.org/). It
1313

1414
### Packages
1515

16-
- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
16+
- `eslint-config-custom`: `eslint` configurations
1717
- `tsconfig`: `tsconfig.json`s used throughout the monorepo
1818

1919
### Utilities
@@ -33,7 +33,6 @@ This repository is a monorepo powered by [Turborepo](https://turborepo.org/). It
3333
| [Docker](https://www.docker.com/get-started/) | 20.10+ |
3434

3535
### Installation
36-
3736
To get the project started, clone this repository:
3837
```sh
3938
# With SSH
@@ -48,21 +47,37 @@ Then install packages:
4847
npm install
4948
```
5049

51-
### Development
50+
If you want to use it there is a development database ready with Docker compose:
51+
```sh
52+
docker-compose up -d
53+
```
54+
55+
Then you need to run the prisma `generate` command:
56+
```sh
57+
# Navigate to the api app directory
58+
cd apps/api
59+
npx prisma generate
60+
```
5261

62+
### Development
5363
To run the project for development use:
5464
```sh
5565
npm run dev
5666
```
5767
It will automatically run the Nuxt and Adonis apps on your `localhost`.
5868

5969
### Build
60-
6170
To build the project use:
6271
```sh
6372
npm run build
6473
```
6574

75+
## Linting
76+
All apps in the repository can be linted with:
77+
```
78+
npm run lint
79+
```
80+
6681
## Tests
6782
Don't forget to test your code before sending a PR.
6883

apps/api/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test('adds 1 + 2 to equal 3', () => {
2+
expect(1 + 2).toBe(3);
3+
});

apps/api/index.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
import { App } from '@tinyhttp/app';
2-
import { logger } from '@tinyhttp/logger';
1+
import Prisma from '@prisma/client';
2+
import { createApi } from './src/create-api';
33

4-
const app = new App();
4+
const prisma = new Prisma.PrismaClient();
5+
const port = +(process.env.PORT ?? '3001');
56

6-
app
7-
.use(logger())
8-
.get('/', (_, res) => res.send('<h1>Hello World</h1>'))
9-
.get('/page/:page/', (req, res) => {
10-
res.status(200).send(`
11-
<h1>Some cool page</h1>
12-
<h2>URL</h2>
13-
${req.url}
14-
<h2>Params</h2>
15-
${JSON.stringify(req.params, null, 2)}
16-
`);
17-
}).listen(3001);
7+
createApi(prisma).listen(port, () => {
8+
// eslint-disable-next-line no-console
9+
console.log('listening on port', port);
10+
});

apps/api/jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2+
export default {
3+
preset: 'ts-jest/presets/default-esm',
4+
testEnvironment: 'node',
5+
};

apps/api/package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,33 @@
55
"main": "index.js",
66
"type": "module",
77
"scripts": {
8-
"dev": "nodemon --watch './**/*.ts' --exec 'node --loader ts-node/esm' ./index.ts"
8+
"start": "node --experimental-specifier-resolution=node --loader ts-node/esm ./index.ts",
9+
"dev": "nodemon -e ts -w \"./**/*.ts\" -x \"npm run start\"",
10+
"lint": "eslint . --cache --fix --ext .js,.ts",
11+
"studio": "npx prisma studio",
12+
"migrate": "npx prisma migrate dev",
13+
"test": "jest"
914
},
1015
"devDependencies": {
16+
"@types/jest": "^27.5.1",
1117
"@types/node": "^17.0.33",
18+
"eslint-config-custom": "*",
19+
"jest": "^28.1.0",
20+
"nodemon": "^2.0.16",
1221
"prisma": "^3.14.0",
22+
"ts-jest": "^28.0.2",
1323
"ts-node": "^10.7.0",
1424
"tsconfig": "*",
1525
"typescript": "^4.6.4"
1626
},
1727
"dependencies": {
1828
"@prisma/client": "^3.14.0",
1929
"@tinyhttp/app": "^2.0.20",
20-
"@tinyhttp/logger": "^1.3.0"
30+
"@tinyhttp/cors": "^2.0.0",
31+
"@tinyhttp/logger": "^1.3.0",
32+
"argon2": "^0.28.5",
33+
"dotenv": "^16.0.1",
34+
"express-validator": "^6.14.0",
35+
"milliparsec": "^2.2.1"
2136
}
2237
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-- CreateTable
2+
CREATE TABLE "Project" (
3+
"id" SERIAL NOT NULL,
4+
"name" TEXT NOT NULL,
5+
6+
CONSTRAINT "Project_pkey" PRIMARY KEY ("id")
7+
);
8+
9+
-- CreateTable
10+
CREATE TABLE "UserProject" (
11+
"userId" INTEGER NOT NULL,
12+
"projectId" INTEGER NOT NULL,
13+
14+
CONSTRAINT "UserProject_pkey" PRIMARY KEY ("userId","projectId")
15+
);
16+
17+
-- CreateTable
18+
CREATE TABLE "Column" (
19+
"id" SERIAL NOT NULL,
20+
"name" TEXT NOT NULL,
21+
"projectId" INTEGER NOT NULL,
22+
23+
CONSTRAINT "Column_pkey" PRIMARY KEY ("id")
24+
);
25+
26+
-- CreateTable
27+
CREATE TABLE "Task" (
28+
"id" SERIAL NOT NULL,
29+
"name" TEXT NOT NULL,
30+
"content" JSONB NOT NULL,
31+
"columnId" INTEGER NOT NULL,
32+
33+
CONSTRAINT "Task_pkey" PRIMARY KEY ("id")
34+
);
35+
36+
-- AddForeignKey
37+
ALTER TABLE "UserProject" ADD CONSTRAINT "UserProject_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
38+
39+
-- AddForeignKey
40+
ALTER TABLE "UserProject" ADD CONSTRAINT "UserProject_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
41+
42+
-- AddForeignKey
43+
ALTER TABLE "Column" ADD CONSTRAINT "Column_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
44+
45+
-- AddForeignKey
46+
ALTER TABLE "Task" ADD CONSTRAINT "Task_columnId_fkey" FOREIGN KEY ("columnId") REFERENCES "Column"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

0 commit comments

Comments
 (0)