Skip to content
Snippets Groups Projects
Commit 98fb2e40 authored by Morris, George (UG - Computer Science)'s avatar Morris, George (UG - Computer Science)
Browse files

WIP: defined connection to db. working on the posts api routes

parent f81728d7
No related branches found
No related tags found
2 merge requests!8CI/CD,!2Posts service
import express from 'express';
import cors from 'cors';
import mongoose from 'mongoose';
import bodyParser from 'body-parser';
import dotenv from 'dotenv';
import postRoutes from './routes/posts.js';
dotenv.config();
const app = express();
app.use(bodyParser.json({ limit: "30mb", extended: true }));
app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }));
app.use(cors());
app.use("/posts", postRoutes);
const PORT = 5002;
mongoose.connect(process.env.CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => app.listen(PORT, "0.0.0.0", () => console.log(`Posts service running on ${PORT}...`)))
.catch((error) => console.log(error.message));
mongoose.set("useFindAndModify", false);
\ No newline at end of file
import express from 'express';
import { getPosts, createPost, getPostById, deletePost, likePost, addComment, removeComment } from '../controllers/posts.js';
const router = express.Router();
//TODO add routes
export default router;
\ 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