Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// src/index.ts
import express, { Request, Response } from 'express';
import cors from 'cors';


const app = express();
const port = 3000;

app.get('/', (req: Request, res: Response) => {
res.send('Hello, TypeScript with Express!');
});

// Use CORS middleware
app.use(cors());


app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});

// New API endpoint
app.get('/awesome/applicant', (req: Request, res: Response) => {
const myInfo = {
name: 'Zubia',
role: 'Student',
funFact: 'I love coding',
};

res.json(myInfo);
});

app.use(cors({
origin: 'http://localhost:3000',
}));

app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});