File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1+ const config = {
2+ passwordProtect : false ,
3+ password : "password"
4+ }
5+ export default config ;
Original file line number Diff line number Diff line change 11import express from 'express'
2+ import basicAuth from "express-basic-auth" ;
23import http from 'node:http'
34import { createBareServer } from '@tomphttp/bare-server-node'
45import path from 'node:path'
56import cors from 'cors'
6-
7+ import config from './config.js'
78const __dirname = process . cwd ( )
89const server = http . createServer ( )
910const app = express ( server )
1011const bareServer = createBareServer ( '/v/' )
1112const PORT = 8080
12-
13+ if ( config . passwordProtect ) {
14+ console . log ( "Password protection is enabled. Username is 'interstellar'." )
15+ console . log ( "Password is: " + config . password )
16+ app . use ( basicAuth ( {
17+ users : { "interstellar" : password } ,
18+ challenge : true
19+ } ) )
20+ }
1321app . use ( express . json ( ) )
1422app . use ( express . urlencoded ( { extended : true } ) )
1523app . use ( cors ( ) )
Original file line number Diff line number Diff line change 1515 "dependencies" : {
1616 "@tomphttp/bare-server-node" : " ^2.0.1" ,
1717 "cors" : " ^2.8.5" ,
18- "express" : " ^4.18.2"
18+ "express" : " ^4.18.2" ,
19+ "express-basic-auth" : " ^1.2.1"
1920 },
2021 "devDependencies" : {
2122 "prettier" : " 3.2.1"
You can’t perform that action at this time.
0 commit comments