diff options
Diffstat (limited to 'vnext')
-rw-r--r-- | vnext/server/Dockerfile | 7 | ||||
-rw-r--r-- | vnext/server/db/index.js | 5 | ||||
-rw-r--r-- | vnext/server/db/users.js | 14 | ||||
-rw-r--r-- | vnext/server/index.js | 4 |
4 files changed, 27 insertions, 3 deletions
diff --git a/vnext/server/Dockerfile b/vnext/server/Dockerfile index 26e962fd..5c08a968 100644 --- a/vnext/server/Dockerfile +++ b/vnext/server/Dockerfile @@ -12,7 +12,8 @@ ENV NODE_ENV=production ENV NPM_CONFIG_LOGLEVEL=warn ENV DEBUG=http -# Expose the listening port of your app -EXPOSE 8081 +RUN useradd juick +USER juick -CMD [ "node", "server.js" ] +EXPOSE 8081 +CMD ["node", "server.js"] diff --git a/vnext/server/db/index.js b/vnext/server/db/index.js new file mode 100644 index 00000000..7a029627 --- /dev/null +++ b/vnext/server/db/index.js @@ -0,0 +1,5 @@ +import postgres from 'postgres' + +const sql = postgres({ database: 'juick', host: process.env.PG_HOST }) + +export default sql diff --git a/vnext/server/db/users.js b/vnext/server/db/users.js new file mode 100644 index 00000000..2201b1ef --- /dev/null +++ b/vnext/server/db/users.js @@ -0,0 +1,14 @@ +import sql from './index' + +/** + * Count users + */ +export async function get_count() { + const count = await sql` + select + count(*) + from users + where banned=0 + ` + return count +} diff --git a/vnext/server/index.js b/vnext/server/index.js index eaf1ae8a..d58fe4c7 100644 --- a/vnext/server/index.js +++ b/vnext/server/index.js @@ -15,6 +15,7 @@ import { instance } from './middleware/mastodon' const PORT = process.env.LISTEN_PORT || 8081 import path from 'path' import { webhook, webhookPath } from './durov' +import { get_count } from './db/users' // initialize the application and create the routes const app = express() @@ -49,6 +50,9 @@ router.use('*', serverRenderer) app.use(router) +get_count().then(count => { + log(`Registered users: ${JSON.stringify(count)}`) +}).catch(log) // start the app app.listen(PORT, (error) => { |