Skip to content

Commit 04da0e0

Browse files
committed
added env file example
1 parent d32ec89 commit 04da0e0

File tree

6 files changed

+94
-158
lines changed

6 files changed

+94
-158
lines changed

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
/node_modules
1+
/node_modules
2+
.DS_store
3+
app-schema.png

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

example.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PORT=8000
2+
DATABASE_HOST=localhost
3+
DATABASE_NAME=NodeNotes
4+
DATABASE_USER=postgres
5+
DATABASE_PASSWORD=postgres
6+
DATABASE_PORT=5432
7+
REDIS_CONNECTION_STRING=redis://127.0.0.1:6379/0
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { createClient, RedisClientType } from 'redis';
2-
3-
export const connectAndGetRedisInstance = async (connectionString?: string): Promise<RedisClientType> => {
4-
const client = await createClient({ url: connectionString })
5-
.on('error', err => console.log('[FATAL] Redis Client Error', err))
6-
.on('connect', () => console.log(`[INFO] Connected to redis at ${connectionString}\n`))
7-
.connect();
8-
9-
return client as RedisClientType
1+
import { createClient, RedisClientType } from 'redis';
2+
3+
export const connectAndGetRedisInstance = async (connectionString?: string): Promise<RedisClientType> => {
4+
const client = await createClient({ url: connectionString })
5+
.on('error', err => console.log('[FATAL] Redis Client Error', err))
6+
.on('connect', () => console.log(`[INFO] Connected to redis at ${connectionString}\n`))
7+
.connect();
8+
9+
return client as RedisClientType
1010
}
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
export const BaseUserSchema = {
2-
type: 'object',
3-
properties: {
4-
login: {
5-
type: 'string',
6-
minLength: 4,
7-
maxLength: 16
8-
},
9-
email: {
10-
type: 'string',
11-
minLength: 8,
12-
maxLength: 60
13-
},
14-
password: {
15-
type: 'string',
16-
minLength: 8,
17-
maxLength: 32
18-
},
19-
username: {
20-
type: 'string',
21-
minLength: 4,
22-
maxLength: 32
23-
},
24-
personalColor: {
25-
type: 'string',
26-
minLength: 6,
27-
maxLength: 13
28-
},
29-
isCollaborating: {
30-
type: 'boolean'
31-
},
32-
createdAt: { type: 'string' },
33-
updatedAt: { type: 'string' }
34-
},
1+
export const BaseUserSchema = {
2+
type: 'object',
3+
properties: {
4+
login: {
5+
type: 'string',
6+
minLength: 4,
7+
maxLength: 16
8+
},
9+
email: {
10+
type: 'string',
11+
minLength: 8,
12+
maxLength: 60
13+
},
14+
password: {
15+
type: 'string',
16+
minLength: 8,
17+
maxLength: 32
18+
},
19+
username: {
20+
type: 'string',
21+
minLength: 4,
22+
maxLength: 32
23+
},
24+
personalColor: {
25+
type: 'string',
26+
minLength: 6,
27+
maxLength: 13
28+
},
29+
isCollaborating: {
30+
type: 'boolean'
31+
},
32+
createdAt: { type: 'string' },
33+
updatedAt: { type: 'string' }
34+
},
3535
} as const

source/openapi/InitSwagger.ts

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import { FastifyInstance } from "fastify"
2-
const swagger = require('@fastify/swagger')
3-
const swaggerUI = require('@fastify/swagger-ui')
4-
5-
export const initSwaggerViewer = async (server: FastifyInstance): Promise<void> => {
6-
await server.register(swagger, {
7-
openapi: {
8-
openapi: '3.0.0',
9-
info: {
10-
title: 'NodeNotes (api - v1)',
11-
description: 'NodeNotes backend REST API endpoints specification',
12-
version: '1.0.0'
13-
},
14-
servers: [
15-
{
16-
url: 'http://localhost:8080',
17-
description: 'Development server'
18-
}
19-
],
20-
tags: [
21-
{ name: 'users', description: 'User related end-points (may require JWT in "Bearer" auth header)' },
22-
{ name: 'auth', description: 'Authorization end-points (may require JWT in "Bearer" auth header)' },
23-
{ name: 'notes', description: 'Note related end-points (requires JWT in "Bearer" auth header)' }
24-
],
25-
externalDocs: {
26-
url: 'https://github.com/LCcodder/NodeNotes',
27-
description: 'GitHub repo'
28-
}
29-
}
30-
})
31-
32-
await server.register(swaggerUI, {
33-
routePrefix: '/documentation',
34-
uiConfig: {
35-
deepLinking: false
36-
},
37-
staticCSP: true,
38-
transformStaticCSP: (header: any) => header,
39-
transformSpecification: (swaggerObject: any, _request: any, _reply: any) => { return swaggerObject },
40-
transformSpecificationClone: true
41-
})
1+
import { FastifyInstance } from "fastify"
2+
const swagger = require('@fastify/swagger')
3+
const swaggerUI = require('@fastify/swagger-ui')
4+
5+
export const initSwaggerViewer = async (server: FastifyInstance): Promise<void> => {
6+
await server.register(swagger, {
7+
openapi: {
8+
openapi: '3.0.0',
9+
info: {
10+
title: 'NodeNotes (api - v1)',
11+
description: 'NodeNotes backend REST API endpoints specification',
12+
version: '1.0.0'
13+
},
14+
servers: [
15+
{
16+
url: 'http://localhost:8080',
17+
description: 'Development server'
18+
}
19+
],
20+
tags: [
21+
{ name: 'users', description: 'User related end-points (may require JWT in "Bearer" auth header)' },
22+
{ name: 'auth', description: 'Authorization end-points (may require JWT in "Bearer" auth header)' },
23+
{ name: 'notes', description: 'Note related end-points (requires JWT in "Bearer" auth header)' }
24+
],
25+
externalDocs: {
26+
url: 'https://github.com/LCcodder/NodeNotes',
27+
description: 'GitHub repo'
28+
}
29+
}
30+
})
31+
32+
await server.register(swaggerUI, {
33+
routePrefix: '/documentation',
34+
uiConfig: {
35+
deepLinking: false
36+
},
37+
staticCSP: true,
38+
transformStaticCSP: (header: any) => header,
39+
transformSpecification: (swaggerObject: any, _request: any, _reply: any) => { return swaggerObject },
40+
transformSpecificationClone: true
41+
})
4242
}

0 commit comments

Comments
 (0)