first commit
This commit is contained in:
commit
0b257d8644
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/
|
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM node:14
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json .
|
||||
COPY package-lock.json .
|
||||
|
||||
# Install npm dependencies
|
||||
# RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
VOLUME /app/data
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "index.js"]
|
16
Dockerfile.old
Normal file
16
Dockerfile.old
Normal file
@ -0,0 +1,16 @@
|
||||
FROM node:14
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json .
|
||||
COPY package-lock.json .
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
VOLUME /app/data
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "index.js"]
|
6
data/nostr.json
Normal file
6
data/nostr.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"names": {
|
||||
"franny": "296842eaaed9be5ae0668da09fe48aac0521c4af859ad547d93145e5ac34c17e",
|
||||
"highperfocused": "480ec1a7516406090dc042ddf67780ef30f26f3a864e83b417c053a5a611c838"
|
||||
}
|
||||
}
|
31
index.json
Normal file
31
index.json
Normal file
@ -0,0 +1,31 @@
|
||||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
app.get('/nostr.json', (req, res) => {
|
||||
const name = req.query.name;
|
||||
fs.readFile(path.join(__dirname, 'data', 'nostr.json'), (err, data) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
res.status(500).send('Internal Server Error');
|
||||
return;
|
||||
}
|
||||
const nostrJson = JSON.parse(data);
|
||||
if (name && nostrJson.names.hasOwnProperty(name)) {
|
||||
const filteredJson = {
|
||||
"names": {
|
||||
[name]: nostrJson.names[name]
|
||||
}
|
||||
};
|
||||
res.json(filteredJson);
|
||||
} else {
|
||||
res.status(404).send('Not found');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on port ${PORT}`);
|
||||
});
|
1182
package-lock.json
generated
Normal file
1182
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
package.json
Normal file
9
package.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "docker-node-json",
|
||||
"version": "1.0.0",
|
||||
"description": "A Docker container hosting a JSON file with filtering capability",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"express": "^4.19.2"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user