const http = require('http'); const { downloadContents, generateZipUrl } = require('./download/download'); const downloadFilesFromGCS = require('./download/gcsArchive'); /** * Create a new HTTP server */ const server = http.createServer((req, res) => { // Set the response HTTP header with HTTP status and Content type // root path if (req.url === '/') { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n'); } else if (req.url === '/downdload') { // ZIPファイルのコンテンツをそのまま返す downloadContents(req, res); } else if (req.url === '/generate-zip') { // ZIPファイルの生成してストレージのURLを返す generateZipUrl(req, res); } else if (req.url === '/downdload-gcs') { // GCSからZIPファイルのコンテンツをそのまま返す downloadFilesFromGCS(req, res); } else { res.statusCode = 404; res.setHeader('Content-Type', 'text/plain'); res.end('Not Found\n'); } }); const port = 3000; server.listen(port, () => { console.log(`Server running at http://localhost:${port}/`); });