-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #452 from Omar-Tood/tood
creating hello world controllers for omar tood
- Loading branch information
Showing
25 changed files
with
137 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
packages/yonode-templates/JS-MongoDB-Prisma-NoAuth-Template/src/controllers/controller.js
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...onode-templates/JS-MongoDB-Prisma-NoAuth-Template/src/controllers/helloWorldController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}); | ||
} | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/yonode-templates/JS-MongoDB-Prisma-NoAuth-Template/src/routes/helloWorldRoutes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
5 changes: 0 additions & 5 deletions
5
packages/yonode-templates/JS-MongoDB-Prisma-NoAuth-Template/src/routes/router.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
packages/yonode-templates/JS-MongoDB-TypeORM-NoAuth-Template/src/controllers/controller.js
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
...node-templates/JS-MongoDB-TypeORM-NoAuth-Template/src/controllers/helloWorldController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
}); | ||
} | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
packages/yonode-templates/JS-MongoDB-TypeORM-NoAuth-Template/src/routes/helloWorldRoutes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
5 changes: 0 additions & 5 deletions
5
packages/yonode-templates/JS-MongoDB-TypeORM-NoAuth-Template/src/routes/router.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
packages/yonode-templates/JS-MySQL-Prisma-NoAuth-Template/src/controllers/controller.js
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
.../yonode-templates/JS-MySQL-Prisma-NoAuth-Template/src/controllers/helloWorldController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
}) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/yonode-templates/JS-MySQL-Prisma-NoAuth-Template/src/routes/helloWorldRoutes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
5 changes: 0 additions & 5 deletions
5
packages/yonode-templates/JS-MySQL-Prisma-NoAuth-Template/src/routes/router.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
packages/yonode-templates/JS-MySQL-TypeORM-NoAuth-Template/src/controllers/controller.js
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...yonode-templates/JS-MySQL-TypeORM-NoAuth-Template/src/controllers/helloWorldController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}); | ||
} | ||
}; | ||
|
8 changes: 8 additions & 0 deletions
8
packages/yonode-templates/JS-MySQL-TypeORM-NoAuth-Template/src/routes/helloWorldRoutes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
5 changes: 0 additions & 5 deletions
5
packages/yonode-templates/JS-MySQL-TypeORM-NoAuth-Template/src/routes/router.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
...es/yonode-templates/JS-PostgreSQL-Sequelize-NoAuth-Template/src/controllers/controller.js
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
...templates/JS-PostgreSQL-Sequelize-NoAuth-Template/src/controllers/helloWorldController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
}) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...s/yonode-templates/JS-PostgreSQL-Sequelize-NoAuth-Template/src/routes/helloWorldRoutes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
5 changes: 0 additions & 5 deletions
5
packages/yonode-templates/JS-PostgreSQL-Sequelize-NoAuth-Template/src/routes/router.js
This file was deleted.
Oops, something went wrong.