This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
-
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
52 changed files
with
26,095 additions
and
16 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,171 @@ | ||
########################################################### | ||
### STANDARD ENV VARIABLES ################################ | ||
########################################################### | ||
|
||
# Set to "production" for live system | ||
NODE_ENV=development | ||
|
||
### SERVICE ############################################### | ||
|
||
# All REQUIRED variables | ||
|
||
# NOTE: Needs to be kept at "0.0.0.0" if using Docker | ||
# Defaults to resolving to localhost if not set | ||
SERVICE_HOST= | ||
SERVICE_PORT=8204 | ||
|
||
### CORS ################################################## | ||
|
||
# Set "Access-Control-Allow-Origin" response header. | ||
# Origin can be comma-delimited string, string, or boolean; | ||
# if set to boolean true then reflect request origin | ||
# (NOTE: this is NOT recommended for production as it enables reflection exploits). | ||
# Defaults to false and disables CORS if not set | ||
CORS_ORIGIN= | ||
|
||
# Set "Access-Control-Allow-Headers" response header. | ||
# Expects comma-delimited string i.e. "Content-Type, Authorization"; | ||
# Defaults to reflecting the headers specified in the | ||
# request's "Access-Control-Request-Headers" header | ||
CORS_ALLOWED_HEADERS="Accept, Accept-Encoding, Accept-Language, Authorization, Content-Type, Origin, X-Forwarded-For, X-Requested-With" | ||
|
||
# Set "Access-Control-Allow-Credentials" response header | ||
# Expects true or to be unset | ||
CORS_ALLOW_CREDENTIALS= | ||
|
||
# Set "Access-Control-Expose-Headers" response header. | ||
# Expects comma-delimited string i.e. "Content-Range, X-Content-Range" or to be unset | ||
CORS_EXPOSED_HEADERS= | ||
|
||
# Set "Access-Control-Max-Age" response header. | ||
# Expects integer or to be unset | ||
CORS_MAX_AGE= | ||
|
||
### DOCKER ################################################ | ||
|
||
# The max amount of processing time the Docker container | ||
# can use of CPU. | ||
# As an example, setting to 0.98 represents 98% of CPU | ||
# processing time of a single core | ||
# Defaults to 0 (use all available processing time) | ||
DOCKER_APP_CPUS= | ||
|
||
# The max amount of memory the Docker container can use. | ||
# As an example, "50M" | ||
# Defaults to 0 (use all available memory) | ||
DOCKER_APP_MEMORY= | ||
|
||
# Refer to https://docs.docker.com/compose/compose-file/compose-file-v3/#restart | ||
# for options. | ||
# Defaults to "unless-stopped" | ||
DOCKER_RESTART_POLICY= | ||
|
||
### HTTPS ################################################# | ||
|
||
# Will use PFX file/passphrase over SSL cert/key if both specified. | ||
# Defaults to serving over HTTP if not set | ||
HTTPS_PFX_PASSPHRASE= | ||
HTTPS_PFX_FILE_PATH= | ||
HTTPS_SSL_CERT_PATH= | ||
HTTPS_SSL_KEY_PATH= | ||
|
||
# Enable HTTP/2 support with HTTP/1.x fallback. | ||
# Requires cert/key supporting TLS 1.2 or above. | ||
# Expects true or to be unset | ||
HTTPS_HTTP2_ENABLED= | ||
|
||
### LOGGER ################################################ | ||
|
||
# Level can be "trace", "debug", "info", "warn", "error", or "fatal". | ||
# Defaults to "info" | ||
LOG_LEVEL= | ||
|
||
# See https://momentjs.com/docs/#/displaying/format/ for | ||
# date format options. | ||
# Requires LOG_ROTATION_FILENAME to be set. | ||
# Defaults to "YYYY-MM-DD" | ||
LOG_ROTATION_DATE_FORMAT= | ||
|
||
# Filename including full path used by the stream, example: | ||
# "./logs/ydh-community-contacts-api-%DATE%.log" | ||
# Defaults to STDOUT. | ||
# Ignored if deployed with Docker Compose, as Docker's | ||
# daemon handles logging and rotations | ||
LOG_ROTATION_FILENAME= | ||
|
||
# Frequency can be "daily", "custom", or "test". Defaults to "daily". | ||
# "test" rotates every minute, set to "custom" if you want to rotate | ||
# based on LOG_ROTATION_DATE_FORMAT. | ||
# Requires LOG_ROTATION_FILENAME to be set. | ||
# Ignored if deployed with Docker Compose. | ||
# Defaults to "daily" | ||
LOG_ROTATION_FREQUENCY= | ||
|
||
# Max number of logs to keep. If not set, it will not remove past logs. | ||
# Requires LOG_ROTATION_FILENAME to be set. | ||
# Defaults to "10" if deployed with Docker Compose | ||
LOG_ROTATION_MAX_LOGS= | ||
|
||
# Max size of the file after which it will rotate. It can | ||
# be combined with frequency or date format. The size units | ||
# are "k", "m" and "g". Units need to directly follow | ||
# a number e.g. 1g, 100m, 20k. | ||
# Requires LOG_ROTATION_FILENAME to be set. | ||
# Defaults to "100m" if deployed with Docker Compose | ||
LOG_ROTATION_MAX_SIZE= | ||
|
||
### PROCESS LOAD HANDLING ################################# | ||
|
||
# If one of the below thresholds is reached then the server | ||
# will return a 503 response until the load has been relieved | ||
|
||
# The max event loop delay in milliseconds | ||
# Defaults to 0 (disabled) | ||
PROC_LOAD_MAX_EVENT_LOOP_DELAY= | ||
|
||
# The max Event Loop Utilization (ELU) | ||
# As an example, setting to 0.98 represents 98% | ||
# Defaults to 0 (disabled) | ||
PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION= | ||
|
||
# The max heap size in bytes | ||
# Defaults to 0 (disabled) | ||
PROC_LOAD_MAX_HEAP_USED_BYTES= | ||
|
||
# The max Resident Set Size (RSS) in bytes | ||
# Defaults to 0 (disabled) | ||
PROC_LOAD_MAX_RSS_BYTES= | ||
|
||
### RATE LIMITING ######################################### | ||
|
||
# List of IPs that are excluded from rate limiting | ||
RATE_LIMIT_EXCLUDED_ARRAY= | ||
|
||
# Maximum number of connections per minute per client | ||
# Defaults to 1000 | ||
RATE_LIMIT_MAX_CONNECTIONS_PER_MIN= | ||
|
||
########################################################### | ||
### PROJECT SPECIFIC ENV VARIABLES ######################## | ||
########################################################### | ||
|
||
### API KEYS ############################################## | ||
|
||
# Example: [{"service": "test", "value": "testtoken"}] | ||
# "value" is the only mandatory value in each object in array. | ||
# Leaving empty will disable bearer token auth | ||
AUTH_BEARER_TOKEN_ARRAY= | ||
|
||
### DATABASE CONNECTION ################################### | ||
|
||
# All REQUIRED variables apart from DB_CLIENT | ||
|
||
# Accepted values are "mssql" and "postgresql". | ||
# Defaults to "mssql" if not set | ||
DB_CLIENT= | ||
|
||
# Examples: | ||
# "mssql:https://username:password@localhost/database" | ||
# "postgresql:https://username:password@localhost:5432/database" | ||
# "Server=localhost,1433;Database=database;User Id=username;Password=password;Encrypt=true" | ||
DB_CONNECTION_STRING= |
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
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
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,18 +1,18 @@ | ||
services: | ||
db: | ||
container_name: ydh-community-contacts-crud-api-db | ||
container_name: ydh-community-contacts-api-db | ||
image: postgres:14-alpine | ||
environment: | ||
POSTGRES_DB: community-contacts_crud_api | ||
POSTGRES_DB: community_contacts_api | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- ydh-community-contacts-crud-api-db-data:/var/lib/postgresql/data | ||
- ydh-community-contacts-api-db-data:/var/lib/postgresql/data | ||
|
||
app: | ||
container_name: ydh-community-contacts-crud-api | ||
container_name: ydh-community-contacts-api | ||
build: | ||
context: . | ||
deploy: | ||
|
@@ -22,7 +22,7 @@ services: | |
memory: "${DOCKER_APP_MEMORY:-0}" | ||
env_file: .env | ||
environment: | ||
DB_CONNECTION_STRING: "postgresql:https://postgres:password@ydh-community-contacts-crud-api-db:5432/community-contacts_crud_api" | ||
DB_CONNECTION_STRING: "postgresql:https://postgres:password@ydh-community-contacts-api-db:5432/community_contacts_api" | ||
LOG_ROTATION_DATE_FORMAT: | ||
LOG_ROTATION_FILENAME: | ||
NODE_ENV: production | ||
|
@@ -38,7 +38,7 @@ services: | |
# See https://github.com/opencontainers/image-spec/blob/master/annotations.md | ||
org.opencontainers.image.authors: Frazer Smith <[email protected]> | ||
org.opencontainers.image.licenses: MIT | ||
org.opencontainers.image.url: https://github.com/Fdawgs/ydh-community-contacts-crud-api | ||
org.opencontainers.image.url: https://github.com/Fdawgs/ydh-community-contacts-api | ||
logging: | ||
options: | ||
max-file: "${LOG_ROTATION_MAX_LOGS:-10}" | ||
|
@@ -49,5 +49,5 @@ services: | |
command: ["npm", "run", "start:migrate"] | ||
|
||
volumes: | ||
ydh-community-contacts-crud-api-db-data: | ||
ydh-community-contacts-api-db-data: | ||
external: false |
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 @@ | ||
SET ANSI_NULLS ON |
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 @@ | ||
SET QUOTED_IDENTIFIER ON |
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 @@ | ||
IF NOT EXISTS ( SELECT name FROM sys.schemas WHERE name = N'lookup' ) EXEC('CREATE SCHEMA lookup'); |
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 @@ | ||
IF OBJECT_ID('lookup.contacts', 'U') IS NULL CREATE TABLE lookup.contacts | ||
( | ||
id uniqueidentifier NOT NULL DEFAULT newid(), | ||
match_type VARCHAR(100) NOT NULL, | ||
match_value VARCHAR(100) NOT NULL, | ||
match_receiver VARCHAR(MAX) NOT NULL, | ||
telecom NVARCHAR(MAX) NOT NULL, | ||
created DATETIME2 NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
last_updated DATETIME2 DEFAULT CURRENT_TIMESTAMP, | ||
CONSTRAINT ck_destination_match PRIMARY KEY (match_type, match_value) | ||
); |
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 @@ | ||
CREATE SCHEMA IF NOT EXISTS lookup; | ||
|
||
CREATE TABLE IF NOT EXISTS lookup.contacts | ||
( | ||
id UUID NOT NULL DEFAULT GEN_RANDOM_UUID(), | ||
match_type VARCHAR(100) NOT NULL, | ||
match_value VARCHAR(100) NOT NULL, | ||
match_receiver VARCHAR NOT NULL, | ||
telecom JSONB NOT NULL, | ||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
CONSTRAINT ck_destination_match PRIMARY KEY (match_type, match_value) | ||
); |
Oops, something went wrong.