diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5574a12..1246ded 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,7 @@ jobs: docker: name: Docker Build and Push runs-on: ubuntu-latest + environment: prod steps: - name: Checkout diff --git a/.github/workflows/cicd-workflow.yml b/.github/workflows/cicd-workflow.yml index 38aaad5..f92b802 100644 --- a/.github/workflows/cicd-workflow.yml +++ b/.github/workflows/cicd-workflow.yml @@ -2,7 +2,7 @@ name: AWS ECS Deployment CI/CD on: push: - branches: [dev] + branches: [prod] jobs: build-and-deploy: diff --git a/index.js b/index.js index 3eb0751..c4b82b0 100755 --- a/index.js +++ b/index.js @@ -1,16 +1,16 @@ -import express from "express"; -import dotenv from "dotenv"; -import cors from "cors"; -import bodyParser from "body-parser"; -import findConfig from "find-config"; -import colors from "colors"; -import connectDB from "./src/configs/database.js"; -import contentRoutes from "./src/routes/contentRoutes.js"; -import categoryRoutes from "./src/routes/categoryRoutes.js"; -import { notFound, errorHandler } from "./src/middleware/errorMiddleware.js"; - -if (process.env.NODE_ENV !== "production") { - dotenv.config({ path: findConfig(".env.dev") }); +import express from 'express'; +import dotenv from 'dotenv'; +import cors from 'cors'; +import bodyParser from 'body-parser'; +import findConfig from 'find-config'; +import colors from 'colors'; +import connectDB from './src/configs/database.js'; +import contentRoutes from './src/routes/contentRoutes.js'; +import categoryRoutes from './src/routes/categoryRoutes.js'; +// import { notFound, errorHandler } from "./src/middleware/errorMiddleware.js"; + +if (process.env.NODE_ENV !== 'production') { + dotenv.config({ path: findConfig('.env.dev') }); } connectDB(); @@ -20,17 +20,22 @@ const app = express(); app.use(cors()); app.use(bodyParser.json({ extended: true })); -app.use("/api/v1/content", contentRoutes); -app.use("/api/v1/category", categoryRoutes); +app.use('/api/v1/content', contentRoutes); +app.use('/api/v1/category', categoryRoutes); -app.use(notFound); -app.use(errorHandler); +// langing message for API +app.get('/', (req, res) => { + res.send('Welcome to Redstream Blog API'); +}); + +// app.use(notFound); +// app.use(errorHandler); const PORT = process.env.PORT || 5000; -if (process.env.NODE_ENV !== "test") { - app.listen(PORT, () => { - console.log(`Server is running on port: ${PORT}`.yellow.bold); - }); +if (process.env.NODE_ENV !== 'test') { + app.listen(PORT, () => { + console.log(`Server is running on port: ${PORT}`.yellow.bold); + }); } export default app;