Files
Campus-Plug/backend/index.js

23 lines
595 B
JavaScript
Raw Normal View History

2025-01-30 13:29:13 -07:00
import express, { json } from "express";
import cors from "cors";
const app = express();
// Middleware
2025-01-30 13:46:49 -07:00
//uses the cors and json middleware
//cors is used to allow cross-origin requests
//json is used to parse the request body
2025-01-30 13:29:13 -07:00
app.use(cors());
app.use(json());
// Sample Route
2025-01-30 13:46:49 -07:00
//This is a sample route that sends a JSON response
//when a GET request is made to /api/test
2025-01-30 13:29:13 -07:00
app.get("/api/test", (req, res) => {
res.json({ message: "Hello from server!" });
});
2025-01-30 13:46:49 -07:00
app.listen(3030, () => {
console.log("\tRunning Backend:");
console.log("\x1b[36m \tLocal:\thttp://localhost:3030/ \x1b[0m");
});