Commit 40667cb7 authored by Рахметова Альбина's avatar Рахметова Альбина

Merge branch '#13' into 'dev'

добавила контроллеры в app

See merge request !17
parents 24bcd78a 631cd4b3
......@@ -36,7 +36,7 @@ export class CommentController {
}
private deleteCommentById = async (req: Request, res: Response): Promise<void> => {
const user = req.user as IUser;
const user = req.body._id;
const id = req.params.id;
const response = await this.service.deleteCommentById(user,id)
res.send(response)
......
import express, {Express, json, urlencoded} from 'express';
import 'dotenv/config';
import cors from 'cors';
import {mongoose} from './repository/mongoose';
import {mongo} from './repository/mongoose';
import {UsersRouter} from './routes/user';
import { CommentController } from './controllers/comments';
import { PostsController } from './controllers/posts';
mongoose.run();
mongo.run();
const app: Express = express();
app.use(json());
......@@ -13,6 +15,9 @@ app.use(urlencoded({extended: true}));
app.use(express.static('public/uploads'));
app.use('/users', UsersRouter);
app.use('/posts', new PostsController().getRouter())
app.use('/comments', new CommentController().getRouter())
app.use('/comments', new CommentController().getRouter())
app.listen(process.env.PORT, () => {
console.log(`App started on port ${process.env.PORT}`);
......
......@@ -7,7 +7,8 @@ const CommentSchema: Schema = new Schema<IComment>({
required: true
},
datetime: {
type: Date
type: Date,
default: Date.now,
},
user: [
{
......
......@@ -11,6 +11,7 @@ import { Comment } from '../models/Comments';
import IUser from '../interfaces/IUser';
export class Mongo implements IDataBase {
[x: string]: any;
private client: Mongoose | null = null
public close = async (): Promise<void> => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment