Skip to content

Commit

Permalink
update (#27)
Browse files Browse the repository at this point in the history
* [Task] #6 provide fallback index.html

* [Task] #6 production ready code (m)

move httpdocs folder to dist
have compile without sourcemaps for faster speed

* [Task] #6 create github action for upload when main is updated (#21)

* [change] #6 new ftp upload action

* [Fix] #6 replace host with server in ftp action

* [Task] #6 basic log (#26)
  • Loading branch information
Type-Style authored Jan 12, 2024
1 parent f66f835 commit 43c1f1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"main": "index.js",
"type": "module",
"scripts": {
"build": "npx tsc && cp -R httpdocs/ dist/",
"clean": "rm -rf dist/*",
"build": "rm -rf dist/* && npx tsc && cp -R httpdocs/ dist/",
"build:prod": "npx tsc -p ./tsconfig.prod.json && cp -R httpdocs/ dist/",
"start": "node dist/app.js",
"dev": "nodemon src/app.ts",
"dev": "rm -rf dist/* && cp -R httpdocs/ dist/ && nodemon src/app.ts",
"lint": "eslint . --fix"
},
"keywords": [],
Expand Down
14 changes: 11 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import express from 'express';
import { Request, Response } from 'express';
import fs from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

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

app.get('/', (req: Request, res: Response) => {
res.send('Hello World, via TypeScript and Node.js!');

res.send('Hello World, via TypeScript and Node.js!');
});

app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
const date = new Date().toLocaleString('de-DE', { hour12: false });
const logPath = join(__dirname, 'httpdocs', 'log.txt');
fs.appendFileSync(logPath, `Express: Server: ${date} \n`);
console.log(`Server läuft unter http://localhost:${port}`);
});

0 comments on commit 43c1f1d

Please sign in to comment.