Skip to content
Snippets Groups Projects
Commit d599c83b authored by Chif Gergő's avatar Chif Gergő
Browse files

Configure mongoose connection, replace Date with string in NewsSchema

parent 07421464
No related branches found
No related tags found
2 merge requests!10Feature/12 dev auto deploy,!6Feature/news api
import "./utils/env"
import express, { Request, Response, NextFunction, Application } from "express";
import mongoose from "mongoose";
import bodyParser from "body-parser";
import expressSession from "express-session";
import authRoute from './routes/auth';
import newsRoute from './routes/news';
mongoose.connect('mongodb://localhost:27017/bodysch', { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true } ).then(
() => { console.log("Connected to database") },
).catch(err => {
console.log("MongoDB connection error. Please make sure MongoDB is running. " + err);
// process.exit();
});
const app: Application = express();
app.use(bodyParser.json()); // for parsing application/json
......
......@@ -11,7 +11,7 @@ interface INews extends Document {
// id: IUser["_id"],
userName: string,
}, */
publishedAt: Date
publishedAt: string
}
const NewsSchema = new Schema({
......@@ -25,7 +25,7 @@ const NewsSchema = new Schema({
id: { type: Schema.Types.ObjectId, required: true },
userName: { type: String, required: true }
}, */
publishedAt: { type: Date, required: true },
publishedAt: { type: String, required: true },
});
export default model<INews>('News', NewsSchema);
\ 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