Skip to content

Commit

Permalink
Merge pull request #452 from Omar-Tood/tood
Browse files Browse the repository at this point in the history
creating hello world controllers for omar tood
  • Loading branch information
sharafdin authored May 11, 2024
2 parents 3ee69e0 + dae9261 commit e43d9b0
Show file tree
Hide file tree
Showing 25 changed files with 137 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import { port } from "./config/initial.config.js";
const app = express();
app.use(express.json());


// use your routes here

app.use("/api/helloworld", helloWorldRouter);



// rest of your code here


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const helloWorld = async (req, res) => {
try {
res.send("Hello World!");
} catch (error) {
res.status(500).json({
message: "Internal Server Error",
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import express from "express";
import { helloWorld } from "../controllers/helloWorldController.js";

const helloWorldRouter = express.Router();

helloWorldRouter.get("/", helloWorld);

export default helloWorldRouter;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import "./config/db.config.js";
const app = express();
app.use(express.json());

// Use Your Route here
pp.use("/api/helloworld", helloWorldRouter);

// rest of your code here


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Hello World controller
*
* This is a simple controller that returns a "Hello World" message
* in the response body. It is a good example of how to create a basic
* controller in Yonode.
*
* @param {Object} res The Express.js response object
* @param {Object} req The Express.js request object
*/
export const helloWorld = async (res, req) => {
try {

// Send a "Hello World" message in the response body
res.send("Hello World");

} catch (err) {
// If there is an error, send a 500 Internal Server Error
// with a message in the response body
res.status(500).json({
message: "Internal Server Error"
});
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import express from 'express'
import { helloWorld } from '../controllers/helloWorldController';

const helloWorldRouter = express.Router()

helloWorldRouter.get("/" , helloWorld)

export default helloWorldRouter;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ app.use(express.json());

// rest of your code here

// Use you Routes here
pp.use("/api/helloworld", helloWorldRouter);


app.listen(port, () => {
console.log(`${chalk.green.bold("Server")} is listening on port ${port}`);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const hellWorld = async (res, req)=>{
try{

res.send("Hello world!")

}catch(err){
res.status(500).json({
message: "Internal Server Error"
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import express from 'express'
import { hellWorld } from '../controllers/helloWorldController.js'

const hellWorldRouter = express.Router()

hellWorldRouter.get("/", hellWorld)

export default hellWorldRouter;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import "./config/db.config.js";
const app = express();
app.use(express.json());


// Use Your Route here

pp.use("/api/helloworld", helloWorldRouter);

// rest of your code here


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* A simple controller function to handle requests to the '/' route
* @param {object} req The request object
* @param {object} res The response object
* @returns {object} The response object
*/
export const helloWorld = async (req, res) => {
try {
// Send a response to the client
res.send("Hello world!");
} catch (err) {
// If there is an error, send a 500 error with a JSON response
res.status(500).json({
message: "Internal Server Error",
});
}
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import express from 'express'
import { helloWorld } from '../controllers/helloWorldController.js'

const helloWorldRouter = express.Router()

helloWorldRouter.get("/", helloWorld)

export default helloWorldRouter;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import './models/models.js';
const app = express();
app.use(express.json());

// User Your Routes here
app.use("/api/helloworld", helloWorldRouter);

// rest of your code here


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

export const helloWorld = async (res, req) => {
try {
// Send a simple string as a response
res.send("Hello World!")
} catch (err) {
// If there's an error, send a response with a 500 status code
// and an error message
res.status(500).json({
message: "Internal Server Error"
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import express from "express"
import { helloWorld } from "../controllers/helloWorldController.js"

const hellWorldRouter = express.Router()

hellWorldRouter.get("/" , helloWorld)

export default hellWorldRouter;

This file was deleted.

0 comments on commit e43d9b0

Please sign in to comment.