Skip to content

Commit ef4861d

Browse files
committed
Initial commit
0 parents  commit ef4861d

25 files changed

+5527
-0
lines changed

.env

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Environment variables declared in this file are automatically made available to Prisma.
2+
3+
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
4+
5+
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
6+
7+
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
8+
9+
DATABASE_URL="postgresql://postgres:123@localhost:5434/nest?schema=public"

.eslintrc.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir : __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
},
18+
ignorePatterns: ['.eslintrc.js'],
19+
rules: {
20+
'@typescript-eslint/interface-name-prefix': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/explicit-module-boundary-types': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
},
25+
};

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
pnpm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
lerna-debug.log*
13+
14+
# OS
15+
.DS_Store
16+
17+
# Tests
18+
/coverage
19+
/.nyc_output
20+
21+
# IDEs and editors
22+
/.idea
23+
.project
24+
.classpath
25+
.c9/
26+
*.launch
27+
.settings/
28+
*.sublime-workspace
29+
30+
# IDE - VSCode
31+
.vscode/*
32+
!.vscode/settings.json
33+
!.vscode/tasks.json
34+
!.vscode/launch.json
35+
!.vscode/extensions.json

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

README.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<p align="center">
2+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
3+
</p>
4+
5+
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6+
[circleci-url]: https://circleci.com/gh/nestjs/nest
7+
8+
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
9+
<p align="center">
10+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
12+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
13+
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
14+
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
15+
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
16+
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
17+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
18+
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
19+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
20+
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
21+
</p>
22+
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
23+
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
24+
25+
## Description
26+
27+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
28+
29+
## Installation
30+
31+
```bash
32+
$ npm install
33+
```
34+
35+
## Running the app
36+
37+
```bash
38+
# development
39+
$ npm run start
40+
41+
# watch mode
42+
$ npm run start:dev
43+
44+
# production mode
45+
$ npm run start:prod
46+
```
47+
48+
## Test
49+
50+
```bash
51+
# unit tests
52+
$ npm run test
53+
54+
# e2e tests
55+
$ npm run test:e2e
56+
57+
# test coverage
58+
$ npm run test:cov
59+
```
60+
61+
## Support
62+
63+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
64+
65+
## Stay in touch
66+
67+
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
68+
- Website - [https://nestjs.com](https://nestjs.com/)
69+
- Twitter - [@nestframework](https://twitter.com/nestframework)
70+
71+
## License
72+
73+
Nest is [MIT licensed](LICENSE).

docker-compose.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3.8'
2+
services:
3+
dev-db:
4+
image: postgres:13
5+
ports:
6+
- 5434:5432
7+
environment:
8+
POSTGRES_USER: postgres
9+
POSTGRES_PASSWORD: 123
10+
POSTGRES_DB: nest
11+
networks:
12+
- freecodecamp
13+
networks:
14+
freecodecamp:

nest-cli.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://json.schemastore.org/nest-cli",
3+
"collection": "@nestjs/schematics",
4+
"sourceRoot": "src"
5+
}

package.json

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "nestjs-api-tutorial",
3+
"version": "0.0.1",
4+
"description": "",
5+
"author": "",
6+
"private": true,
7+
"license": "UNLICENSED",
8+
"scripts": {
9+
"prebuild": "rimraf dist",
10+
"build": "nest build",
11+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
12+
"start": "nest start",
13+
"start:dev": "nest start --watch",
14+
"start:debug": "nest start --debug --watch",
15+
"start:prod": "node dist/main",
16+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
17+
"test": "jest",
18+
"test:watch": "jest --watch",
19+
"test:cov": "jest --coverage",
20+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
21+
"test:e2e": "jest --config ./test/jest-e2e.json"
22+
},
23+
"dependencies": {
24+
"@nestjs/common": "^8.0.0",
25+
"@nestjs/core": "^8.0.0",
26+
"@nestjs/platform-express": "^8.0.0",
27+
"@prisma/client": "^3.13.0",
28+
"reflect-metadata": "^0.1.13",
29+
"rimraf": "^3.0.2",
30+
"rxjs": "^7.2.0"
31+
},
32+
"devDependencies": {
33+
"@nestjs/cli": "^8.0.0",
34+
"@nestjs/schematics": "^8.0.0",
35+
"@nestjs/testing": "^8.0.0",
36+
"@types/express": "^4.17.13",
37+
"@types/jest": "27.4.1",
38+
"@types/node": "^16.0.0",
39+
"@types/supertest": "^2.0.11",
40+
"@typescript-eslint/eslint-plugin": "^5.0.0",
41+
"@typescript-eslint/parser": "^5.0.0",
42+
"eslint": "^8.0.1",
43+
"eslint-config-prettier": "^8.3.0",
44+
"eslint-plugin-prettier": "^4.0.0",
45+
"jest": "^27.2.5",
46+
"prettier": "^2.3.2",
47+
"prisma": "^3.13.0",
48+
"source-map-support": "^0.5.20",
49+
"supertest": "^6.1.3",
50+
"ts-jest": "^27.0.3",
51+
"ts-loader": "^9.2.3",
52+
"ts-node": "^10.0.0",
53+
"tsconfig-paths": "^3.10.1",
54+
"typescript": "^4.3.5"
55+
},
56+
"jest": {
57+
"moduleFileExtensions": [
58+
"js",
59+
"json",
60+
"ts"
61+
],
62+
"rootDir": "src",
63+
"testRegex": ".*\\.spec\\.ts$",
64+
"transform": {
65+
"^.+\\.(t|j)s$": "ts-jest"
66+
},
67+
"collectCoverageFrom": [
68+
"**/*.(t|j)s"
69+
],
70+
"coverageDirectory": "../coverage",
71+
"testEnvironment": "node"
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- CreateTable
2+
CREATE TABLE "User" (
3+
"id" TEXT NOT NULL,
4+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
5+
"updatedAt" TIMESTAMP(3) NOT NULL,
6+
"email" TEXT NOT NULL,
7+
"hash" TEXT NOT NULL,
8+
"firstName" TEXT,
9+
"lastName" TEXT,
10+
11+
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
12+
);
13+
14+
-- CreateTable
15+
CREATE TABLE "Bookmark" (
16+
"id" TEXT NOT NULL,
17+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
18+
"updatedAt" TIMESTAMP(3) NOT NULL,
19+
"title" TEXT NOT NULL,
20+
"description" TEXT,
21+
"link" TEXT NOT NULL,
22+
23+
CONSTRAINT "Bookmark_pkey" PRIMARY KEY ("id")
24+
);

prisma/migrations/migration_lock.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Please do not edit this file manually
2+
# It should be added in your version-control system (i.e. Git)
3+
provider = "postgresql"

prisma/schema.prisma

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// This is your Prisma schema file,
2+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
3+
4+
generator client {
5+
provider = "prisma-client-js"
6+
}
7+
8+
datasource db {
9+
provider = "postgresql"
10+
url = env("DATABASE_URL")
11+
}
12+
13+
model User {
14+
id String @id @default(uuid())
15+
createdAt DateTime @default(now())
16+
updatedAt DateTime @updatedAt
17+
18+
email String
19+
hash String
20+
21+
firstName String?
22+
lastName String?
23+
}
24+
25+
model Bookmark{
26+
id String @id @default(uuid())
27+
createdAt DateTime @default(now())
28+
updatedAt DateTime @updatedAt
29+
30+
title String
31+
description String?
32+
link String
33+
}

src/app.module.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Module } from '@nestjs/common';
2+
3+
import { AuthModule } from './auth/auth.module';
4+
import { BookmarkModule } from './bookmark/bookmark.module';
5+
import { UserModule } from './user/user.module';
6+
import { PrismaModule } from './prisma/prisma.module';
7+
8+
@Module({
9+
imports: [AuthModule, UserModule, BookmarkModule, PrismaModule],
10+
})
11+
export class AppModule {}

src/auth/auth.controller.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Controller, Post } from '@nestjs/common';
2+
3+
import { AuthService } from './auth.service';
4+
5+
@Controller('auth')
6+
export class AuthController {
7+
constructor(private authService: AuthService) {}
8+
9+
@Post('signup')
10+
signup() {
11+
return this.authService.signup();
12+
}
13+
14+
@Post('signin')
15+
signin() {
16+
return this.authService.signin();
17+
}
18+
}

src/auth/auth.module.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Module } from '@nestjs/common';
2+
import { AuthController } from './auth.controller';
3+
import { AuthService } from './auth.service';
4+
5+
@Module({
6+
controllers: [AuthController],
7+
providers: [AuthService],
8+
})
9+
export class AuthModule {}

src/auth/auth.service.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Injectable } from '@nestjs/common';
2+
3+
@Injectable({})
4+
export class AuthService {
5+
signup() {
6+
return 'I am sign up 1';
7+
}
8+
9+
signin() {
10+
return 'I am sign in';
11+
}
12+
}

src/bookmark/bookmark.module.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Module } from '@nestjs/common';
2+
3+
@Module({})
4+
export class BookmarkModule {}

src/main.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { NestFactory } from '@nestjs/core';
2+
import { AppModule } from './app.module';
3+
4+
async function bootstrap() {
5+
const app = await NestFactory.create(AppModule);
6+
await app.listen(3000);
7+
}
8+
bootstrap();

src/prisma/prisma.module.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Module } from '@nestjs/common';
2+
import { PrismaService } from './prisma.service';
3+
4+
@Module({
5+
providers: [PrismaService],
6+
})
7+
export class PrismaModule {}

src/prisma/prisma.service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Injectable } from '@nestjs/common';
2+
3+
@Injectable()
4+
export class PrismaService {}

src/user/user.module.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Module } from '@nestjs/common';
2+
3+
@Module({})
4+
export class UserModule {}

0 commit comments

Comments
 (0)