generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ardnaxelas
committed
Sep 24, 2024
1 parent
a34d67e
commit 536b9c3
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:18 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
|
||
COPY . . | ||
|
||
EXPOSE 3000 | ||
|
||
CMD [ "npm", "start" ] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const express = require('express'); | ||
const { Database } = require('arangojs'); | ||
|
||
const app = express(); | ||
const port = 3000; | ||
|
||
const db = new Database({ | ||
url: 'http://arango:8529', // то имя сервиса в docker-compose | ||
auth: { username: 'root', password: 'password' } | ||
}); | ||
|
||
// Маршрут для проверки базы данных и вывода "Hello World" | ||
app.get('/', async (req, res) => { | ||
try { | ||
await db.version(); | ||
res.send('Hello World'); | ||
} catch (err) { | ||
console.error('Ошибка подключения к базе данных:', err); | ||
res.status(500).send('Не удалось подключиться к базе данных'); | ||
} | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Сервер запущен на порту ${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: '3.8' | ||
|
||
services: | ||
arango: | ||
image: arangodb:latest | ||
environment: | ||
- ARANGO_ROOT_PASSWORD=password | ||
ports: | ||
- "8529:8529" | ||
volumes: | ||
- arango_data:/var/lib/arangodb3 | ||
|
||
nodeapp: | ||
build: . | ||
depends_on: | ||
- arango | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
- NODE_ENV=production | ||
volumes: | ||
- .:/usr/src/app | ||
|
||
volumes: | ||
arango_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "arango-hello-world", | ||
"version": "1.0.0", | ||
"description": "проверка работы ArangoDB", | ||
"main": "app.js", | ||
"scripts": { | ||
"start": "node app.js" | ||
}, | ||
"dependencies": { | ||
"arangojs": "^9.0.0", | ||
"express": "^4.21.0" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |