-
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
0 parents
commit 4df58a9
Showing
18 changed files
with
1,344 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,10 @@ | ||
plugins: | ||
eslint: | ||
enabled: true | ||
channel: "eslint-5" | ||
duplication: | ||
enabled: true | ||
config: | ||
languages: | ||
javascript: | ||
mass_threshold: 60 |
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,9 @@ | ||
/node_modules/ | ||
/.nyc_output/ | ||
/coverage | ||
/builds | ||
/*.log | ||
/.git/ | ||
/test/ | ||
/*.md | ||
/.* |
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,84 @@ | ||
--- | ||
env: | ||
node: true | ||
es6: true | ||
parserOptions: | ||
ecmaVersion: 2018 | ||
rules: | ||
no-dupe-args: error | ||
no-dupe-keys: error | ||
no-duplicate-case: error | ||
no-extra-parens: warn | ||
no-unreachable: error | ||
no-unexpected-multiline: warn | ||
valid-typeof: error | ||
curly: | ||
- warn | ||
- multi | ||
no-alert: error | ||
no-else-return: error | ||
no-eq-null: error | ||
no-eval: warn | ||
no-implicit-coercion: error | ||
no-implied-eval: error | ||
no-iterator: error | ||
no-loop-func: error | ||
no-multi-str: error | ||
no-proto: error | ||
no-redeclare: error | ||
no-self-assign: error | ||
no-self-compare: error | ||
no-useless-return: error | ||
no-void: error | ||
no-with: error | ||
require-await: error | ||
no-unused-vars: | ||
- warn | ||
- vars: local | ||
no-use-before-define: | ||
- error | ||
- functions: false | ||
block-spacing: | ||
- warn | ||
- always | ||
brace-style: | ||
- warn | ||
- stroustrup | ||
- allowSingleLine: true | ||
camelcase: error | ||
comma-spacing: error | ||
comma-style: error | ||
func-call-spacing: error | ||
indent: | ||
- error | ||
- 4 | ||
- SwitchCase: 1 | ||
key-spacing: error | ||
keyword-spacing: | ||
- warn | ||
- before: true | ||
after: false | ||
overrides: | ||
case: | ||
after: true | ||
return: | ||
after: true | ||
throw: | ||
after: true | ||
var: | ||
after: true | ||
const: | ||
after: true | ||
let: | ||
after: true | ||
line-comment-position: error | ||
max-params: | ||
- error | ||
- 4 | ||
no-tabs: error | ||
quotes: | ||
- warn | ||
- single | ||
linebreak-style: | ||
- error | ||
- windows |
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 @@ | ||
*.js text eol=crlf |
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 @@ | ||
/node_modules/ | ||
/.nyc_output/ | ||
/coverage | ||
/builds | ||
/*.log |
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,83 @@ | ||
stages: | ||
- test | ||
- build | ||
- deploy | ||
|
||
include: | ||
- template: Dependency-Scanning.gitlab-ci.yml | ||
- template: SAST.gitlab-ci.yml | ||
- template: Code-Quality.gitlab-ci.yml | ||
|
||
# Make quality report downloadable | ||
code_quality: | ||
artifacts: | ||
paths: [gl-code-quality-report.json] | ||
|
||
sast: | ||
variables: | ||
SAST_EXCLUDED_PATHS: test/** | ||
|
||
# Lint js files. | ||
lint-js: | ||
image: node | ||
stage: test | ||
tags: | ||
- docker | ||
script: | ||
- npm install -g eslint | ||
- eslint --ignore-pattern "**/*.min.js" $CI_PROJECT_DIR | ||
|
||
# Performs unit testing. | ||
unit-test: | ||
variables: | ||
MONGO_HOST: mongo:27017 | ||
services: | ||
- mongo | ||
coverage: '/Statements\s*:\s*(\d+(?:\.\d+)?\%)/' | ||
image: registry.gitlab.com/gcsboss/docker-mocha-nyc:0.1.0-alpine | ||
stage: test | ||
artifacts: | ||
paths: [coverage] | ||
tags: | ||
- docker | ||
script: | ||
- npm i . | ||
- npm run-script coverage | ||
|
||
# # Build and Push Docker image. | ||
# build-image: | ||
# image: docker:19.03.1 | ||
# stage: build | ||
# needs: | ||
# - lint-js | ||
# - unit-test | ||
# tags: | ||
# - docker | ||
# only: | ||
# - tags | ||
# except: | ||
# variables: | ||
# - $CI_COMMIT_TAG =~ /beta/ | ||
# script: | ||
# - docker login -u gcsboss -p $HUB_PUSH_TOKEN | ||
# - docker build -t gcsboss/okaeri:$CI_COMMIT_REF_NAME . | ||
# - docker build -t gcsboss/okaeri:latest . | ||
# - docker push gcsboss/okaeri:$CI_COMMIT_REF_NAME | ||
# - docker push gcsboss/okaeri:latest | ||
|
||
# Publish package to NPM. | ||
publish: | ||
stage: deploy | ||
image: node | ||
tags: | ||
- docker | ||
only: | ||
- tags | ||
- triggers | ||
except: | ||
variables: | ||
- $CI_COMMIT_TAG =~ /beta/ | ||
script: | ||
- npm install -g npm-cli-login | ||
- npm-cli-login | ||
- npm publish |
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,12 @@ | ||
# Okaeri Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [v0.0.1] - 2020-01-18 | ||
|
||
First officially released version | ||
|
||
[v0.0.1]: https://gitlab.com/GCSBOSS/okaeri/-/tags/v0.0.1 |
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,20 @@ | ||
FROM 'node:13-alpine' | ||
ENV NODE_ENV production | ||
|
||
EXPOSE 80 | ||
# VOLUME /usr/src/app/events.log | ||
# VOLUME /usr/src/app/conf.toml | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN addgroup -g 2000 -S okaeri && \ | ||
adduser -u 2000 -S okaeri -G okaeri && \ | ||
chown okaeri:okaeri /usr/src/app | ||
|
||
USER okaeri | ||
|
||
COPY package*.json ./ | ||
RUN npm i -P | ||
COPY . . | ||
|
||
CMD ["node", "./bin/okaeri.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Guilherme C. Souza | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,97 @@ | ||
# [Okaeri](https://gitlab.com/GCSBOSS/okaeri) | ||
|
||
The RESTful microservice for managing user accounts and authentication | ||
|
||
- [Simple REST API](#api-reference) | ||
- [Highly configurable](#configuration-reference) | ||
- [Complete event log](#logging) | ||
- [Webhooks for all important events](#webhooks) | ||
|
||
## Get Started | ||
|
||
1. Install with: `npm i -g okaeri`. | ||
2. Optionally point `OKAERI_CONF` env var to a TOML [config file](#configuration). | ||
3. Setup your MongoDB instance on localhost:27017 | ||
4. Run in the terminal with: `okaeri`. | ||
|
||
## Get Started with Docker | ||
|
||
The official image repository in Docker Hub is `gcsboss/okaeri`. | ||
|
||
Run like this: `docker run -p 7667:7667 -v /your/conf.toml:/usr/src/app/conf.toml gcsboss/okaeri` | ||
|
||
## API Reference | ||
|
||
The following endpoints are supported so far: | ||
|
||
- `POST /account`: Create a new account | ||
- Expects a JSON payload contaning a `name` string and a strong `password` string. | ||
|
||
|
||
- `POST /auth`: Verifies whether a password and name match an active account. | ||
- Expects a JSON payload contaning a correct `name` and `password` for the account being verified. | ||
|
||
## Configuration Reference | ||
|
||
This are all the avaiable settings to be defined in your `conf.toml`. | ||
|
||
```toml | ||
# Define the server port | ||
port = 7667 # Defaults to 7667 | ||
|
||
# Setup your connection to mongodb | ||
[mongo] | ||
url = 'mongodb://localhost:27017/' # Defaults to localhost on port 27017 | ||
name = 'MyDBName' # Defaults to "Okaeri" | ||
|
||
``` | ||
|
||
### Logging | ||
|
||
Okaeri can log all events in JSON format so you may easily parse and trsnaform it | ||
as per your needs. You can also tweak the log level so you get only the | ||
right informatin for you. | ||
|
||
Available log levels are: `debug`, `info`, `warn`, `error`, `fatal`. | ||
|
||
```toml | ||
[log] | ||
level = 'debug' # Defaults to "info" | ||
file = '/home/me/okaeri.log' # Defaults to the project installation dir | ||
``` | ||
|
||
### Webhooks | ||
|
||
You can setup webhooks to be triggered whenever important events happen within | ||
Okaeri. By default all webhooks are sent as: | ||
- POST requests | ||
- Payload contains JSON with event data | ||
- Header 'X-Okaeri-Event' caintains the event type | ||
|
||
Check the supported events so far: | ||
|
||
```toml | ||
[hooks] | ||
onCreateAccount = 'http://example.com/let/me/know' | ||
``` | ||
|
||
## Reporting Bugs | ||
If you have found any problems with this module, please: | ||
|
||
1. [Open an issue](https://gitlab.com/GCSBOSS/okaeri/issues/new). | ||
2. Describe what happened and how. | ||
3. Also in the issue text, reference the label `~bug`. | ||
|
||
We will make sure to take a look when time allows us. | ||
|
||
## Proposing Features | ||
If you wish to get that awesome feature or have some advice for us, please: | ||
1. [Open an issue](https://gitlab.com/GCSBOSS/okaeri/issues/new). | ||
2. Describe your ideas. | ||
3. Also in the issue text, reference the label `~proposal`. | ||
|
||
## Contributing | ||
If you have spotted any enhancements to be made and is willing to get your hands | ||
dirty about it, fork us and | ||
[submit your merge request](https://gitlab.com/GCSBOSS/okaeri/merge_requests/new) | ||
so we can collaborate effectively. |
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,7 @@ | ||
#!node | ||
|
||
const { run } = require('nodecaf'); | ||
run({ | ||
init: require('../lib/main'), | ||
confPath: process.env.OKAERI_CONF || './conf.toml' | ||
}); |
Oops, something went wrong.