server.js
angular/examples/week05-06/server.js
const express = require('express');
const cors = require('cors');
const app = express();
const PORT = process.env.PORT || 4000;
app.use(cors());
app.use(express.json());
// Mock metrics data
app.get('/api/metrics/summary', (req, res) => {
const metrics = [
{ id: '1', label: 'Total Users', value: 1234, delta: 12 },
{ id: '2', label: 'Active Projects', value: 56, delta: -3 },
{ id: '3', label: 'Revenue', value: 98765, delta: 8 },
{ id: '4', label: 'Tasks Completed', value: 234, delta: 15 },
];
console.log('📊 Metrics requested');
res.json(metrics);
});
// Mock projects data
app.get('/api/projects', (req, res) => {
const projects = [
{ name: 'Project Alpha', status: 'active' },
{ name: 'Project Beta', status: 'completed' },
{ name: 'Project Gamma', status: 'active' },
{ name: 'Project Delta', status: 'pending' },
];
console.log('📁 Projects requested');
res.json(projects);
});
app.listen(PORT, () => {
console.log(`Backend listening on http://localhost:${PORT}`);
});
관련 글
server.js
server.js — javascript source code from the angular learning materials (angular/comprehensive-demo/server/server.js).
글 읽기 →app.component.ts
app.component.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.component.ts).
글 읽기 →app.config.ts
app.config.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.config.ts).
글 읽기 →app.routes.ts
app.routes.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.routes.ts).
글 읽기 →auth.guard.ts
auth.guard.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/core/guards/auth.guard.ts).
글 읽기 →role.guard.ts
role.guard.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/core/guards/role.guard.ts).
글 읽기 →