-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
21 changed files
with
11,399 additions
and
2 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,14 @@ | ||
# JS generated files from TS | ||
dist/**/* | ||
|
||
app.js | ||
app.d.ts | ||
app.js.map | ||
lib/**/*.d.ts | ||
lib/**/*.js.map | ||
lib/**/*.js | ||
|
||
|
||
# tests | ||
features/**/*.js | ||
form/ |
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,8 @@ | ||
{ | ||
"plugins": ["kuzzle"], | ||
"extends": [ | ||
"plugin:kuzzle/default", | ||
"plugin:kuzzle/node", | ||
"plugin:kuzzle/typescript" | ||
] | ||
} |
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,11 @@ | ||
name: Backend - ESLint | ||
description: Run ESLint for backend | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: run backend lint | ||
shell: bash | ||
run: | | ||
cd backend | ||
npm ci | ||
npm run lint |
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,10 @@ | ||
name: Backend - Functional Tests | ||
description: Run Functional Tests for backend | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Run backend functional test | ||
shell: bash | ||
run: | | ||
npm ci | ||
npm run test |
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,47 @@ | ||
name: Pull request checks | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
- uses: ./.github/actions/lint | ||
|
||
functional-tests: | ||
name: Functional Tests | ||
runs-on: ubuntu-22.04 | ||
needs: [lint] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
- uses: ./.github/actions/test |
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,50 @@ | ||
name: Push checks | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
- uses: ./.github/actions/lint | ||
|
||
functional-tests: | ||
name: Functional Tests | ||
runs-on: ubuntu-22.04 | ||
needs: [lint] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
- uses: ./.github/actions/test |
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,11 @@ | ||
# Node | ||
*.log | ||
node_modules/ | ||
|
||
# Other | ||
.DS_STORE | ||
*# | ||
*~ | ||
|
||
# Build files | ||
dist/**/* |
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,30 @@ | ||
FROM kuzzleio/kuzzle-runner:16 as builder | ||
|
||
ADD . /var/app | ||
|
||
WORKDIR /var/app | ||
|
||
RUN npm ci | ||
RUN npm run build | ||
|
||
FROM kuzzleio/kuzzle-runner:16 as prepare | ||
|
||
WORKDIR /var/app | ||
ENV NODE_ENV=production | ||
|
||
COPY --from=builder /var/app/package*.json /var/app/.npmrc* /var/app/dist ./ | ||
RUN npm install --production | ||
|
||
# Final image | ||
FROM node:16-stretch-slim as production | ||
|
||
ARG KUZZLE_VAULT_KEY | ||
ENV KUZZLE_VAULT_KEY=$KUZZLE_VAULT_KEY | ||
|
||
ENV NODE_ENV=production | ||
|
||
WORKDIR /var/app | ||
|
||
COPY --from=prepare /var/app/ ./ | ||
|
||
CMD [ "node", "app.js" ] |
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 |
---|---|---|
@@ -1,2 +1,19 @@ | ||
# template-kuzzle-project | ||
Official template for a new kuzzle project | ||
# Kuzzle Application | ||
|
||
_An application running with [Kuzzle](https://github.com/kuzzleio/kuzzle)_ | ||
|
||
## Installation and run | ||
|
||
Requirement: | ||
- Node.js = 18 | ||
- NPM = 10.1.0 | ||
- Docker | ||
- Docker-Compose | ||
|
||
First, install [Kourou](https://github.com/kuzzleio/kourou), the Kuzzle CLI: `npm install -g kourou` | ||
|
||
# Usage | ||
|
||
```bash | ||
docker compose up -d | ||
``` |
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,5 @@ | ||
import { MyApplication } from "./lib/MyApplication"; | ||
|
||
const app = new MyApplication(); | ||
|
||
app.start(); |
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,55 @@ | ||
version: "3" | ||
|
||
services: | ||
api: | ||
image: kuzzleio/kuzzle-runner:18 | ||
command: sh /var/app/start.sh api | ||
volumes: | ||
- .:/var/app | ||
- ~/.npmrc:/root/.npmrc | ||
depends_on: | ||
redis: | ||
condition: service_healthy | ||
elasticsearch: | ||
condition: service_healthy | ||
ports: | ||
- "7512:7512" | ||
- "7511:7511" | ||
- "7510:7510" | ||
- "9229:9229" | ||
- "1883:1883" | ||
environment: | ||
- kuzzle_services__storageEngine__client__node=http://elasticsearch:9200 | ||
- kuzzle_services__storageEngine__commonMapping__dynamic=true | ||
- kuzzle_services__internalCache__node__host=redis | ||
- kuzzle_services__memoryStorage__node__host=redis | ||
- NODE_ENV=${NODE_ENV:-development} | ||
- DEBUG=${DEBUG:-none} | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://api:7512/_healthcheck"] | ||
timeout: 5s | ||
interval: 5s | ||
retries: 30 | ||
|
||
redis: | ||
image: redis:5 | ||
ports: | ||
- "6379:6379" | ||
healthcheck: | ||
test: ["CMD", "redis-cli", "ping"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 30 | ||
|
||
elasticsearch: | ||
image: kuzzleio/elasticsearch:7 | ||
volumes: | ||
- "/tmp/snapshots:/tmp/snapshots" | ||
ports: | ||
- "9200:9200" | ||
- "9300:9300" | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://elasticsearch:9200"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 30 |
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 @@ | ||
{ | ||
"killDelay": "5000", | ||
"nodeArgs": [ | ||
"--inspect=0.0.0.0:9229", | ||
"-r", | ||
"ts-node/register" | ||
], | ||
"watch": [ | ||
"app.ts", | ||
"lib", | ||
"node_modules" | ||
] | ||
} |
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,8 @@ | ||
export default { | ||
moduleDirectories: ["node_modules", "lib"], | ||
moduleNameMapper: { | ||
"^lib/(.*)$": "<rootDir>/lib/$1", | ||
}, | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
}; |
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,38 @@ | ||
import { Backend } from "kuzzle"; | ||
import { PrometheusPlugin } from "kuzzle-plugin-prometheus"; | ||
|
||
export type MyApplicationConfig = { | ||
someValue: string; | ||
|
||
another: { | ||
value: number; | ||
}; | ||
}; | ||
|
||
export class MyApplication extends Backend { | ||
public configuration: MyApplicationConfig; | ||
private prometheusPlugin = new PrometheusPlugin(); | ||
|
||
get appConfig() { | ||
return this.config.content.application as MyApplicationConfig; | ||
} | ||
|
||
constructor(config?: MyApplicationConfig) { | ||
super("my-application"); | ||
|
||
if (config) { | ||
this.configuration = config; | ||
} else { | ||
this.configuration = this.config.content | ||
.application as MyApplicationConfig; | ||
} | ||
|
||
this.plugin.use(this.prometheusPlugin); | ||
} | ||
|
||
async start() { | ||
await super.start(); | ||
|
||
this.log.info("Application started"); | ||
} | ||
} |
Empty file.
Oops, something went wrong.