Skip to content
Snippets Groups Projects
Commit 2c227abe authored by L4168's avatar L4168
Browse files

login/register logic, added Docker support

parent a4da26c7
No related branches found
No related tags found
No related merge requests found
npm-debug.log
\ No newline at end of file
variableName='variableValue'
\ No newline at end of file
# compiled output # compiled output
/dist /dist
/node_modules /node_modules
package-lock.json
# Logs # Logs
logs logs
......
FROM node:10.15.3
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD [ "npm", "start", "--force" ]
\ No newline at end of file
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
$ npm install $ npm install
``` ```
Name .env.example to .env and ormconfig.json.example to ormconfig.json and add values accordingly Name .env.example to .env and ormconfig.json.example to ormconfig.json and add values accordingly.
Needed postgresql modules: Needed postgresql modules:
```bash ```bash
# Inside the database that you're connecting to: # Inside the database that you're connecting to:
......
version: "3"
services:
ehasa-frontend:
image: "ehasa/frontend"
ports:
- 8080:80
ehasa-backend:
image: "ehasa/backend"
ports:
- 5000:5000
postgres:
image: postgres
volumes:
- /home/postgres:/var/lib/postgresql/data
ports:
- 5432:5432
\ No newline at end of file
{
"type": "",
"host": "",
"port": ,
"username": "",
"password": "",
"database": "",
"entities": ["src/**/*.entity{.ts,.js}"],
"synchronize": true,
"logging": true
}
\ No newline at end of file
This diff is collapsed.
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
"prettier": "^1.15.3", "prettier": "^1.15.3",
"supertest": "^3.4.1", "supertest": "^3.4.1",
"ts-jest": "24.0.2", "ts-jest": "24.0.2",
"ts-node": "8.1.0", "ts-node": "^8.1.0",
"tsconfig-paths": "3.8.0", "tsconfig-paths": "3.8.0",
"tslint": "5.16.0", "tslint": "5.16.0",
"typescript": "3.4.3", "typescript": "3.4.3",
......
...@@ -6,6 +6,6 @@ async function bootstrap() { ...@@ -6,6 +6,6 @@ async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
// Cors is needed for application/json POST // Cors is needed for application/json POST
app.enableCors(); app.enableCors();
await app.listen(3000); await app.listen(5000);
} }
bootstrap(); bootstrap();
import { Controller, Post, Body, UsePipes, ValidationPipe, Get, UseGuards } from '@nestjs/common'; import { Controller, Post, Body, UsePipes, ValidationPipe, Get, UseGuards, Req } from '@nestjs/common';
import { UserService } from './user.service'; import { UserService } from './user.service';
import { UserDTO } from './user.dto'; import { UserDTO } from './user.dto';
...@@ -6,7 +6,7 @@ import { AuthGuard } from 'src/shared/auth.guard'; ...@@ -6,7 +6,7 @@ import { AuthGuard } from 'src/shared/auth.guard';
@Controller('user') @Controller('user')
export class UserController { export class UserController {
constructor(private userService: UserService) {} constructor(private userService: UserService) { }
@Post('register') @Post('register')
@UsePipes(new ValidationPipe()) @UsePipes(new ValidationPipe())
...@@ -20,9 +20,10 @@ export class UserController { ...@@ -20,9 +20,10 @@ export class UserController {
return this.userService.login(data); return this.userService.login(data);
} }
@Get('map') // verifies the token
@Get('verify')
@UseGuards(new AuthGuard()) @UseGuards(new AuthGuard())
showMap() { showMap() {
return 'karttanäkymä accessed'; return true;
} }
} }
...@@ -28,7 +28,7 @@ export class PersonEntity { ...@@ -28,7 +28,7 @@ export class PersonEntity {
id, name id, name
}, },
process.env.SECRET, process.env.SECRET,
{ expiresIn: '15min'}, { expiresIn: '7d'},
); );
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment