Skip to content

Commit

Permalink
feat: Version 1 Added For Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh-live committed Jan 28, 2024
1 parent c3f3405 commit 2f52413
Show file tree
Hide file tree
Showing 8 changed files with 1,172 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.example
@@ -0,0 +1,2 @@
PORT=3000
MONGO_URI=mongodb://localhost:27017/test
32 changes: 32 additions & 0 deletions Controllers/HelloWorld.js
@@ -0,0 +1,32 @@
/**
* Responds with a JSON object containing the message "Hello, World!".
* @param {Request} req - The request object.
* @param {Response} res - The response object.
*/
function getHelloWorld(req, res) {
// Extract request details
const requestDetails = {
method: req.method,
url: req.url,
headers: req.headers,
params: req.params,
query: req.query,
body: req.body
};

// Create a message object
const message = {
message: "Hello, World!"
};

// Send the message as JSON
res.json({
...requestDetails,
...message
});
}


module.exports = {
getHelloWorld,
};
15 changes: 15 additions & 0 deletions Routes/api.js
@@ -0,0 +1,15 @@
// Routes/api.js

const express = require('express');
const router = express.Router();

// Import the HelloWorld controller
const helloWorldController = require('../Controllers/HelloWorld');


// Define a sample API route using the controller
router.get('/', helloWorldController.getHelloWorld);

// Define other API routes as needed

module.exports = router;
11 changes: 11 additions & 0 deletions Routes/views.js
@@ -0,0 +1,11 @@
// Routes/views.js

const express = require('express');
const router = express.Router();

// Serve the index.html file for the root path with cache control set to 5 minutes
router.use('/', express.static('Views', { index: 'index.html', maxAge: '5m' }));

// Define other view routes as needed

module.exports = router;
46 changes: 46 additions & 0 deletions Views/index.html
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Congratulations Page</title>
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(to right, #4a69bb, #283c86);
color: #fff;
text-align: center;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}

.container {
max-width: 600px;
padding: 40px;
background-color: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

h1 {
color: #4a69bb;
}

p {
color: #333;
}
</style>
</head>
<body>

<div class="container">
<h1>Congratulations!</h1>
<p>You have successfully created @ngtv/create-node-app</p>
</div>

</body>
</html>
28 changes: 28 additions & 0 deletions app.js
@@ -0,0 +1,28 @@
// Import the required modules
const express = require('express');

// Create an instance of the Express application
const app = express();

// Set the port to the value specified in the environment variable, or default to 3000
const port = process.env.PORT || 3000;

// Set the host to the value specified in the environment variable, or default to 'localhost'
const host = process.env.HOST || 'localhost';

// Import the routes for views and API
const viewsRoutes = require('./Routes/views');
const apiRoutes = require('./Routes/api');

// Use the views routes for the root path
app.use('/', viewsRoutes);

// Use the API routes for the '/api' path
app.use('/api', apiRoutes);

// Start the server and listen on the specified port and host
app.listen(port, () => {
console.log(`Server running at http://${host}:${port}/`);
});

// End of the code

0 comments on commit 2f52413

Please sign in to comment.