Created
March 11, 2024 02:33
-
-
Save kunxin-chor/66156224e3ee16db09c34b968f140e05 to your computer and use it in GitHub Desktop.
RESTFul API Template
This file contains hidden or 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
// 1. REQUIRE DEPENDENCIES | |
const express = require('express'); | |
const mongodb = require('mongodb'); | |
const cors = require('cors'); | |
const app = express(); | |
// enable the use of JSON | |
app.use(express.json()); | |
// enable CORS | |
app.use(express.cors()); | |
// 2. SETUP ROUTES | |
app.get('/api', function(req,res){ | |
res.send("API is running"); | |
}) | |
// 3. ENABLE THE SERVER | |
app.listen(3000, function(){ | |
console.log("Server has started"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment