File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 1+ export const config = {
2+ passwordProtect : false ,
3+ password : "password"
4+ }
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 === true ) {
14+ console . log ( "Password protection is enabled. Username is 'interstellar'." )
15+ console . log ( "Password is: " + config . password )
16+ app . use ( basicAuth ( {
17+ users : { "interstellar" : config . password } ,
18+ challenge : true
19+ } ) )
20+ } else {
21+ console . log ( "Password protection is disabled." )
22+ }
1323app . use ( express . json ( ) )
1424app . use ( express . urlencoded ( { extended : true } ) )
1525app . use ( cors ( ) )
Original file line number Diff line number Diff line change 88 },
99 "scripts" : {
1010 "start" : " node index.js" ,
11- "format" : " npx prettier . --write"
11+ "format" : " npx prettier . --write" ,
12+ "password-start" : " node password.js"
1213 },
1314 "author" : " " ,
1415 "license" : " GPL-3.0-or-later" ,
1516 "dependencies" : {
16- "@titaniumnetwork-dev/ultraviolet" : " ^1.0.10" ,
1717 "@tomphttp/bare-server-node" : " ^2.0.1" ,
1818 "cors" : " ^2.8.5" ,
19- "express" : " ^4.18.2"
19+ "express" : " ^4.18.2" ,
20+ "express-basic-auth" : " ^1.2.1"
2021 },
2122 "devDependencies" : {
2223 "prettier" : " 3.2.1"
You can’t perform that action at this time.
0 commit comments