finish base
This commit is contained in:
parent
03759b1d42
commit
e1a2dc249e
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"typescript": true,
|
||||||
|
"commands": [
|
||||||
|
"./commands",
|
||||||
|
"@adonisjs/core/build/commands/index.js",
|
||||||
|
"@adonisjs/repl/build/commands",
|
||||||
|
"@adonisjs/lucid/build/commands"
|
||||||
|
],
|
||||||
|
"exceptionHandlerNamespace": "App/Exceptions/Handler",
|
||||||
|
"aliases": {
|
||||||
|
"App": "app",
|
||||||
|
"Config": "config",
|
||||||
|
"Database": "database",
|
||||||
|
"Contracts": "contracts"
|
||||||
|
},
|
||||||
|
"preloads": [
|
||||||
|
"./start/routes",
|
||||||
|
"./start/kernel"
|
||||||
|
],
|
||||||
|
"providers": [
|
||||||
|
"./providers/AppProvider",
|
||||||
|
"@adonisjs/core",
|
||||||
|
"@adonisjs/lucid"
|
||||||
|
],
|
||||||
|
"aceProviders": [
|
||||||
|
"@adonisjs/repl"
|
||||||
|
],
|
||||||
|
"tests": {
|
||||||
|
"suites": [
|
||||||
|
{
|
||||||
|
"name": "functional",
|
||||||
|
"files": [
|
||||||
|
"tests/functional/**/*.spec(.ts|.js)"
|
||||||
|
],
|
||||||
|
"timeout": 60000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"testProviders": [
|
||||||
|
"@japa/preset-adonis/TestsProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.json]
|
||||||
|
insert_final_newline = false
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
PORT=3333
|
||||||
|
HOST=0.0.0.0
|
||||||
|
NODE_ENV=development
|
||||||
|
APP_KEY=lbWiz3KKfnBB9ML_nqWzUwH4eeIQ6w7n
|
||||||
|
DRIVE_DISK=local
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
MYSQL_HOST=localhost
|
||||||
|
MYSQL_PORT=3306
|
||||||
|
MYSQL_USER=lucid
|
||||||
|
MYSQL_PASSWORD=
|
||||||
|
MYSQL_DB_NAME=lucid
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
node_modules
|
||||||
|
build
|
||||||
|
coverage
|
||||||
|
.vscode
|
||||||
|
.DS_STORE
|
||||||
|
.env
|
||||||
|
tmp
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Ace Commands
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This file is the entry point for running ace commands.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
require('reflect-metadata')
|
||||||
|
require('source-map-support').install({ handleUncaughtExceptions: false })
|
||||||
|
|
||||||
|
const { Ignitor } = require('@adonisjs/core/build/standalone')
|
||||||
|
new Ignitor(__dirname)
|
||||||
|
.ace()
|
||||||
|
.handle(process.argv.slice(2))
|
||||||
|
|
@ -0,0 +1,575 @@
|
||||||
|
{
|
||||||
|
"commands": {
|
||||||
|
"dump:rcfile": {
|
||||||
|
"settings": {},
|
||||||
|
"commandPath": "@adonisjs/core/build/commands/DumpRc",
|
||||||
|
"commandName": "dump:rcfile",
|
||||||
|
"description": "Dump contents of .adonisrc.json file along with defaults",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": []
|
||||||
|
},
|
||||||
|
"list:routes": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true,
|
||||||
|
"stayAlive": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/core/build/commands/ListRoutes/index",
|
||||||
|
"commandName": "list:routes",
|
||||||
|
"description": "List application routes",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "verbose",
|
||||||
|
"propertyName": "verbose",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Display more information"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "reverse",
|
||||||
|
"propertyName": "reverse",
|
||||||
|
"type": "boolean",
|
||||||
|
"alias": "r",
|
||||||
|
"description": "Reverse routes display"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "methods",
|
||||||
|
"propertyName": "methodsFilter",
|
||||||
|
"type": "array",
|
||||||
|
"alias": "m",
|
||||||
|
"description": "Filter routes by method"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "patterns",
|
||||||
|
"propertyName": "patternsFilter",
|
||||||
|
"type": "array",
|
||||||
|
"alias": "p",
|
||||||
|
"description": "Filter routes by the route pattern"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "names",
|
||||||
|
"propertyName": "namesFilter",
|
||||||
|
"type": "array",
|
||||||
|
"alias": "n",
|
||||||
|
"description": "Filter routes by route name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "json",
|
||||||
|
"propertyName": "json",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Output as JSON"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "table",
|
||||||
|
"propertyName": "table",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Output as Table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "max-width",
|
||||||
|
"propertyName": "maxWidth",
|
||||||
|
"type": "number",
|
||||||
|
"description": "Specify maximum rendering width. Ignored for JSON Output"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generate:key": {
|
||||||
|
"settings": {},
|
||||||
|
"commandPath": "@adonisjs/core/build/commands/GenerateKey",
|
||||||
|
"commandName": "generate:key",
|
||||||
|
"description": "Generate a new APP_KEY secret",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": []
|
||||||
|
},
|
||||||
|
"repl": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true,
|
||||||
|
"environment": "repl",
|
||||||
|
"stayAlive": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/repl/build/commands/AdonisRepl",
|
||||||
|
"commandName": "repl",
|
||||||
|
"description": "Start a new REPL session",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": []
|
||||||
|
},
|
||||||
|
"db:seed": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/DbSeed",
|
||||||
|
"commandName": "db:seed",
|
||||||
|
"description": "Execute database seeders",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection for the seeders",
|
||||||
|
"alias": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "interactive",
|
||||||
|
"propertyName": "interactive",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Run seeders in interactive mode",
|
||||||
|
"alias": "i"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "files",
|
||||||
|
"propertyName": "files",
|
||||||
|
"type": "array",
|
||||||
|
"description": "Define a custom set of seeders files names to run",
|
||||||
|
"alias": "f"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "compact-output",
|
||||||
|
"propertyName": "compactOutput",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "A compact single-line output"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"db:wipe": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/DbWipe",
|
||||||
|
"commandName": "db:wipe",
|
||||||
|
"description": "Drop all tables, views and types in database",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection",
|
||||||
|
"alias": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "drop-views",
|
||||||
|
"propertyName": "dropViews",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Drop all views"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "drop-types",
|
||||||
|
"propertyName": "dropTypes",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Drop all custom types (Postgres only)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "force",
|
||||||
|
"propertyName": "force",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Explicitly force command to run in production"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"db:truncate": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/DbTruncate",
|
||||||
|
"commandName": "db:truncate",
|
||||||
|
"description": "Truncate all tables in database",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection",
|
||||||
|
"alias": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "force",
|
||||||
|
"propertyName": "force",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Explicitly force command to run in production"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"make:model": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/MakeModel",
|
||||||
|
"commandName": "make:model",
|
||||||
|
"description": "Make a new Lucid model",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"propertyName": "name",
|
||||||
|
"name": "name",
|
||||||
|
"required": true,
|
||||||
|
"description": "Name of the model class"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "migration",
|
||||||
|
"propertyName": "migration",
|
||||||
|
"type": "boolean",
|
||||||
|
"alias": "m",
|
||||||
|
"description": "Generate the migration for the model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "controller",
|
||||||
|
"propertyName": "controller",
|
||||||
|
"type": "boolean",
|
||||||
|
"alias": "c",
|
||||||
|
"description": "Generate the controller for the model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "factory",
|
||||||
|
"propertyName": "factory",
|
||||||
|
"type": "boolean",
|
||||||
|
"alias": "f",
|
||||||
|
"description": "Generate a factory for the model"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"make:migration": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/MakeMigration",
|
||||||
|
"commandName": "make:migration",
|
||||||
|
"description": "Make a new migration file",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"propertyName": "name",
|
||||||
|
"name": "name",
|
||||||
|
"required": true,
|
||||||
|
"description": "Name of the migration file"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "The connection flag is used to lookup the directory for the migration file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "folder",
|
||||||
|
"propertyName": "folder",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Pre-select a migration directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "create",
|
||||||
|
"propertyName": "create",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define the table name for creating a new table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "table",
|
||||||
|
"propertyName": "table",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define the table name for altering an existing table"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"make:seeder": {
|
||||||
|
"settings": {},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/MakeSeeder",
|
||||||
|
"commandName": "make:seeder",
|
||||||
|
"description": "Make a new Seeder file",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"propertyName": "name",
|
||||||
|
"name": "name",
|
||||||
|
"required": true,
|
||||||
|
"description": "Name of the seeder class"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": []
|
||||||
|
},
|
||||||
|
"make:factory": {
|
||||||
|
"settings": {},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/MakeFactory",
|
||||||
|
"commandName": "make:factory",
|
||||||
|
"description": "Make a new factory",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"propertyName": "model",
|
||||||
|
"name": "model",
|
||||||
|
"required": true,
|
||||||
|
"description": "The name of the model"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "model-path",
|
||||||
|
"propertyName": "modelPath",
|
||||||
|
"type": "string",
|
||||||
|
"description": "The path to the model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "exact",
|
||||||
|
"propertyName": "exact",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Create the factory with the exact name as provided",
|
||||||
|
"alias": "e"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"migration:run": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/Migration/Run",
|
||||||
|
"commandName": "migration:run",
|
||||||
|
"description": "Migrate database by running pending migrations",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection",
|
||||||
|
"alias": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "force",
|
||||||
|
"propertyName": "force",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Explicitly force to run migrations in production"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dry-run",
|
||||||
|
"propertyName": "dryRun",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Do not run actual queries. Instead view the SQL output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "compact-output",
|
||||||
|
"propertyName": "compactOutput",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "A compact single-line output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "disable-locks",
|
||||||
|
"propertyName": "disableLocks",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Disable locks acquired to run migrations safely"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"migration:rollback": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/Migration/Rollback",
|
||||||
|
"commandName": "migration:rollback",
|
||||||
|
"description": "Rollback migrations to a specific batch number",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection",
|
||||||
|
"alias": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "force",
|
||||||
|
"propertyName": "force",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Explictly force to run migrations in production"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dry-run",
|
||||||
|
"propertyName": "dryRun",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Do not run actual queries. Instead view the SQL output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "batch",
|
||||||
|
"propertyName": "batch",
|
||||||
|
"type": "number",
|
||||||
|
"description": "Define custom batch number for rollback. Use 0 to rollback to initial state"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "compact-output",
|
||||||
|
"propertyName": "compactOutput",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "A compact single-line output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "disable-locks",
|
||||||
|
"propertyName": "disableLocks",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Disable locks acquired to run migrations safely"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"migration:status": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/Migration/Status",
|
||||||
|
"commandName": "migration:status",
|
||||||
|
"description": "View migrations status",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection",
|
||||||
|
"alias": "c"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"migration:reset": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/Migration/Reset",
|
||||||
|
"commandName": "migration:reset",
|
||||||
|
"description": "Rollback all migrations",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection",
|
||||||
|
"alias": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "force",
|
||||||
|
"propertyName": "force",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Explicitly force command to run in production"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dry-run",
|
||||||
|
"propertyName": "dryRun",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Do not run actual queries. Instead view the SQL output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "disable-locks",
|
||||||
|
"propertyName": "disableLocks",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Disable locks acquired to run migrations safely"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"migration:refresh": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/Migration/Refresh",
|
||||||
|
"commandName": "migration:refresh",
|
||||||
|
"description": "Rollback and migrate database",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection",
|
||||||
|
"alias": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "force",
|
||||||
|
"propertyName": "force",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Explicitly force command to run in production"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dry-run",
|
||||||
|
"propertyName": "dryRun",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Do not run actual queries. Instead view the SQL output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "seed",
|
||||||
|
"propertyName": "seed",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Run seeders"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "disable-locks",
|
||||||
|
"propertyName": "disableLocks",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Disable locks acquired to run migrations safely"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"migration:fresh": {
|
||||||
|
"settings": {
|
||||||
|
"loadApp": true
|
||||||
|
},
|
||||||
|
"commandPath": "@adonisjs/lucid/build/commands/Migration/Fresh",
|
||||||
|
"commandName": "migration:fresh",
|
||||||
|
"description": "Drop all tables and re-migrate the database",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": [
|
||||||
|
{
|
||||||
|
"name": "connection",
|
||||||
|
"propertyName": "connection",
|
||||||
|
"type": "string",
|
||||||
|
"description": "Define a custom database connection",
|
||||||
|
"alias": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "force",
|
||||||
|
"propertyName": "force",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Explicitly force command to run in production"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "seed",
|
||||||
|
"propertyName": "seed",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Run seeders"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "drop-views",
|
||||||
|
"propertyName": "dropViews",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Drop all views"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "drop-types",
|
||||||
|
"propertyName": "dropTypes",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Drop all custom types (Postgres only)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "disable-locks",
|
||||||
|
"propertyName": "disableLocks",
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Disable locks acquired to run migrations safely"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"aliases": {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Http Exception Handler
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| AdonisJs will forward all exceptions occurred during an HTTP request to
|
||||||
|
| the following class. You can learn more about exception handling by
|
||||||
|
| reading docs.
|
||||||
|
|
|
||||||
|
| The exception handler extends a base `HttpExceptionHandler` which is not
|
||||||
|
| mandatory, however it can do lot of heavy lifting to handle the errors
|
||||||
|
| properly.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Logger from '@ioc:Adonis/Core/Logger'
|
||||||
|
import HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler'
|
||||||
|
|
||||||
|
export default class ExceptionHandler extends HttpExceptionHandler {
|
||||||
|
constructor () {
|
||||||
|
super(Logger)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
import fs from "fs";
|
||||||
|
import chokidar from "chokidar";
|
||||||
|
import moment from "moment";
|
||||||
|
import LogDetectFile from "App/Models/LogDetectFile";
|
||||||
|
import LogReport from "App/Models/LogReport";
|
||||||
|
|
||||||
|
// export default class loggerAPI {
|
||||||
|
export function runtimeCheckLogs(folderPath) {
|
||||||
|
console.log(folderPath)
|
||||||
|
try {
|
||||||
|
let fileList = [];
|
||||||
|
let fileList_old = [];
|
||||||
|
// Function to update the list of files
|
||||||
|
async function updateFileList() {
|
||||||
|
let dateNow = moment(Date.now()).format("YYYY/MM/DD");
|
||||||
|
fileList = fs.readdirSync(folderPath);
|
||||||
|
// console.log("File list updated:", fileList);
|
||||||
|
|
||||||
|
fileList.map((file) => {
|
||||||
|
const filePath = `${folderPath}/${file}`;
|
||||||
|
const stats = fs.statSync(filePath);
|
||||||
|
|
||||||
|
//scan file today
|
||||||
|
if (dateNow !== moment(stats.mtime).format("YYYY/MM/DD")) {
|
||||||
|
fileList = fileList.filter((i) => i !== file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch the folder for new files
|
||||||
|
const folderWatcher = chokidar.watch(folderPath);
|
||||||
|
// folderWatcher.setMaxListeners(20);
|
||||||
|
|
||||||
|
folderWatcher.on("add", async (filePath) => {
|
||||||
|
console.log(`New file added: ${filePath}`);
|
||||||
|
//import log new file
|
||||||
|
await LogDetectFile.firstOrCreate({file_name:filePath.split("\\")[filePath.split("\\").length -1]},{file_name:filePath.split("\\")[filePath.split("\\").length -1]})
|
||||||
|
// updateFile;
|
||||||
|
fileList_old = fileList;
|
||||||
|
updateFileList();
|
||||||
|
watchFilesInList();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Watch for changes in the files listed
|
||||||
|
function watchFilesInList() {
|
||||||
|
// console.log("--------->", fileList);
|
||||||
|
//get date now
|
||||||
|
|
||||||
|
//check new file
|
||||||
|
fileList
|
||||||
|
?.filter((i) => fileList_old.includes(i) === false)
|
||||||
|
?.forEach((fileName) => {
|
||||||
|
//path file
|
||||||
|
const filePath = `${folderPath}/${fileName}`;
|
||||||
|
//get date modified
|
||||||
|
// const stats = fs.statSync(filePath);
|
||||||
|
// //scan file today
|
||||||
|
// if (dateNow === moment(stats.mtime).format("2023/08/20")) {
|
||||||
|
const scan = fs.watchFile(
|
||||||
|
filePath,
|
||||||
|
{ interval: 10000 },
|
||||||
|
async (eventType) => {
|
||||||
|
//check special item, extra RAM, error in log
|
||||||
|
|
||||||
|
//true: import log to log_report table, send report to Zulip
|
||||||
|
const log = await LogDetectFile.findBy('file_name', fileName)
|
||||||
|
await LogReport.create({
|
||||||
|
detected_content: 'virk',
|
||||||
|
line: 123,
|
||||||
|
id_file: log?.id_ldf
|
||||||
|
})
|
||||||
|
//false: next
|
||||||
|
console.log(`${fileName} has changed (${eventType})`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//setMaxListeners
|
||||||
|
scan.setMaxListeners(0);
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { DateTime } from 'luxon'
|
||||||
|
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
|
||||||
|
export default class LogDetectFile extends BaseModel {
|
||||||
|
|
||||||
|
public static table = 'log_detect_files'
|
||||||
|
|
||||||
|
@column({ isPrimary: true })
|
||||||
|
public id_ldf: number
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public file_name: string
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true })
|
||||||
|
public created_at: DateTime
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||||
|
public updated_at: DateTime
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { DateTime } from 'luxon'
|
||||||
|
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
|
||||||
|
export default class LogReport extends BaseModel {
|
||||||
|
|
||||||
|
public static table = 'log_reports'
|
||||||
|
|
||||||
|
@column({ isPrimary: true })
|
||||||
|
public id_report: number
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public detected_content: string
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public line: number
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public id_file: number
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true })
|
||||||
|
public created_at: DateTime
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||||
|
public updated_at: DateTime
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
hukljksdsdf
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
,mb
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { listDirectoryFiles } from '@adonisjs/core/build/standalone'
|
||||||
|
import Application from '@ioc:Adonis/Core/Application'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Exporting an array of commands
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Instead of manually exporting each file from this directory, we use the
|
||||||
|
| helper `listDirectoryFiles` to recursively collect and export an array
|
||||||
|
| of filenames.
|
||||||
|
|
|
||||||
|
| Couple of things to note:
|
||||||
|
|
|
||||||
|
| 1. The file path must be relative from the project root and not this directory.
|
||||||
|
| 2. We must ignore this file to avoid getting into an infinite loop
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export default listDirectoryFiles(__dirname, Application.appRoot, ['./commands/index'])
|
||||||
|
|
@ -0,0 +1,235 @@
|
||||||
|
/**
|
||||||
|
* Config source: https://git.io/JfefZ
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this config
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import proxyAddr from 'proxy-addr'
|
||||||
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
|
import type { ServerConfig } from '@ioc:Adonis/Core/Server'
|
||||||
|
import type { LoggerConfig } from '@ioc:Adonis/Core/Logger'
|
||||||
|
import type { ProfilerConfig } from '@ioc:Adonis/Core/Profiler'
|
||||||
|
import type { ValidatorConfig } from '@ioc:Adonis/Core/Validator'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application secret key
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The secret to encrypt and sign different values in your application.
|
||||||
|
| Make sure to keep the `APP_KEY` as an environment variable and secure.
|
||||||
|
|
|
||||||
|
| Note: Changing the application key for an existing app will make all
|
||||||
|
| the cookies invalid and also the existing encrypted data will not
|
||||||
|
| be decrypted.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const appKey: string = Env.get('APP_KEY')
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Http server configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The configuration for the HTTP(s) server. Make sure to go through all
|
||||||
|
| the config properties to make keep server secure.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const http: ServerConfig = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Allow method spoofing
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Method spoofing enables defining custom HTTP methods using a query string
|
||||||
|
| `_method`. This is usually required when you are making traditional
|
||||||
|
| form requests and wants to use HTTP verbs like `PUT`, `DELETE` and
|
||||||
|
| so on.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
allowMethodSpoofing: false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Subdomain offset
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
subdomainOffset: 2,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Request Ids
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting this value to `true` will generate a unique request id for each
|
||||||
|
| HTTP request and set it as `x-request-id` header.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
generateRequestId: false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Trusting proxy servers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define the proxy servers that AdonisJs must trust for reading `X-Forwarded`
|
||||||
|
| headers.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
trustProxy: proxyAddr.compile('loopback'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Generating Etag
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Whether or not to generate an etag for every response.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
etag: false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| JSONP Callback
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
jsonpCallbackName: 'callback',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cookie settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
cookie: {
|
||||||
|
domain: '',
|
||||||
|
path: '/',
|
||||||
|
maxAge: '2h',
|
||||||
|
httpOnly: true,
|
||||||
|
secure: false,
|
||||||
|
sameSite: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Force Content Negotiation
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The internals of the framework relies on the content negotiation to
|
||||||
|
| detect the best possible response type for a given HTTP request.
|
||||||
|
|
|
||||||
|
| However, it is a very common these days that API servers always wants to
|
||||||
|
| make response in JSON regardless of the existence of the `Accept` header.
|
||||||
|
|
|
||||||
|
| By setting `forceContentNegotiationTo = 'application/json'`, you negotiate
|
||||||
|
| with the server in advance to always return JSON without relying on the
|
||||||
|
| client to set the header explicitly.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
forceContentNegotiationTo: 'application/json',
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Logger
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
export const logger: LoggerConfig = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The name of the application you want to add to the log. It is recommended
|
||||||
|
| to always have app name in every log line.
|
||||||
|
|
|
||||||
|
| The `APP_NAME` environment variable is automatically set by AdonisJS by
|
||||||
|
| reading the `name` property from the `package.json` file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
name: Env.get('APP_NAME'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Toggle logger
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Enable or disable logger application wide
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
enabled: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Logging level
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The level from which you want the logger to flush logs. It is recommended
|
||||||
|
| to make use of the environment variable, so that you can define log levels
|
||||||
|
| at deployment level and not code level.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
level: Env.get('LOG_LEVEL', 'info'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Pretty print
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| It is highly advised NOT to use `prettyPrint` in production, since it
|
||||||
|
| can have huge impact on performance.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
prettyPrint: Env.get('NODE_ENV') === 'development',
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Profiler
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
export const profiler: ProfilerConfig = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Toggle profiler
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Enable or disable profiler
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
enabled: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Blacklist actions/row labels
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define an array of actions or row labels that you want to disable from
|
||||||
|
| getting profiled.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
blacklist: [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Whitelist actions/row labels
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define an array of actions or row labels that you want to whitelist for
|
||||||
|
| the profiler. When whitelist is defined, then `blacklist` is ignored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
whitelist: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Validator
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure the global configuration for the validator. Here's the reference
|
||||||
|
| to the default config https://git.io/JT0WE
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const validator: ValidatorConfig = {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,211 @@
|
||||||
|
/**
|
||||||
|
* Config source: https://git.io/Jfefn
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this config
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { BodyParserConfig } from '@ioc:Adonis/Core/BodyParser'
|
||||||
|
|
||||||
|
const bodyParserConfig: BodyParserConfig = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| White listed methods
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| HTTP methods for which body parsing must be performed. It is a good practice
|
||||||
|
| to avoid body parsing for `GET` requests.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
whitelistedMethods: ['POST', 'PUT', 'PATCH', 'DELETE'],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| JSON parser settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The settings for the JSON parser. The types defines the request content
|
||||||
|
| types which gets processed by the JSON parser.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
json: {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
limit: '1mb',
|
||||||
|
strict: true,
|
||||||
|
types: [
|
||||||
|
'application/json',
|
||||||
|
'application/json-patch+json',
|
||||||
|
'application/vnd.api+json',
|
||||||
|
'application/csp-report',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Form parser settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The settings for the `application/x-www-form-urlencoded` parser. The types
|
||||||
|
| defines the request content types which gets processed by the form parser.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
form: {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
limit: '1mb',
|
||||||
|
queryString: {},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Convert empty strings to null
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Convert empty form fields to null. HTML forms results in field string
|
||||||
|
| value when the field is left blank. This option normalizes all the blank
|
||||||
|
| field values to "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
convertEmptyStringsToNull: true,
|
||||||
|
|
||||||
|
types: [
|
||||||
|
'application/x-www-form-urlencoded',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Raw body parser settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Raw body just reads the request body stream as a plain text, which you
|
||||||
|
| can process by hand. This must be used when request body type is not
|
||||||
|
| supported by the body parser.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
raw: {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
limit: '1mb',
|
||||||
|
queryString: {},
|
||||||
|
types: [
|
||||||
|
'text/*',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Multipart parser settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The settings for the `multipart/form-data` parser. The types defines the
|
||||||
|
| request content types which gets processed by the form parser.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
multipart: {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Auto process
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The auto process option will process uploaded files and writes them to
|
||||||
|
| the `tmp` folder. You can turn it off and then manually use the stream
|
||||||
|
| to pipe stream to a different destination.
|
||||||
|
|
|
||||||
|
| It is recommended to keep `autoProcess=true`. Unless you are processing bigger
|
||||||
|
| file sizes.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
autoProcess: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Files to be processed manually
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You can turn off `autoProcess` for certain routes by defining
|
||||||
|
| routes inside the following array.
|
||||||
|
|
|
||||||
|
| NOTE: Make sure the route pattern starts with a leading slash.
|
||||||
|
|
|
||||||
|
| Correct
|
||||||
|
| ```js
|
||||||
|
| /projects/:id/file
|
||||||
|
| ```
|
||||||
|
|
|
||||||
|
| Incorrect
|
||||||
|
| ```js
|
||||||
|
| projects/:id/file
|
||||||
|
| ```
|
||||||
|
*/
|
||||||
|
processManually: [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Temporary file name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When auto processing is on. We will use this method to compute the temporary
|
||||||
|
| file name. AdonisJs will compute a unique `tmpPath` for you automatically,
|
||||||
|
| However, you can also define your own custom method.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
// tmpFileName () {
|
||||||
|
// },
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encoding
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Request body encoding
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
encoding: 'utf-8',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Convert empty strings to null
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Convert empty form fields to null. HTML forms results in field string
|
||||||
|
| value when the field is left blank. This option normalizes all the blank
|
||||||
|
| field values to "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
convertEmptyStringsToNull: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Max Fields
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The maximum number of fields allowed in the request body. The field includes
|
||||||
|
| text inputs and files both.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
maxFields: 1000,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Request body limit
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The total limit to the multipart body. This includes all request files
|
||||||
|
| and fields data.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
limit: '20mb',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Types
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The types that will be considered and parsed as multipart body.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
types: [
|
||||||
|
'multipart/form-data',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default bodyParserConfig
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
/**
|
||||||
|
* Config source: https://git.io/JfefC
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this config
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { CorsConfig } from '@ioc:Adonis/Core/Cors'
|
||||||
|
|
||||||
|
const corsConfig: CorsConfig = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enabled
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| A boolean to enable or disable CORS integration from your AdonisJs
|
||||||
|
| application.
|
||||||
|
|
|
||||||
|
| Setting the value to `true` will enable the CORS for all HTTP request. However,
|
||||||
|
| you can define a function to enable/disable it on per request basis as well.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
enabled: false,
|
||||||
|
|
||||||
|
// You can also use a function that return true or false.
|
||||||
|
// enabled: (request) => request.url().startsWith('/api')
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Origin
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Set a list of origins to be allowed for `Access-Control-Allow-Origin`.
|
||||||
|
| The value can be one of the following:
|
||||||
|
|
|
||||||
|
| https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
|
||||||
|
|
|
||||||
|
| Boolean (true) - Allow current request origin.
|
||||||
|
| Boolean (false) - Disallow all.
|
||||||
|
| String - Comma separated list of allowed origins.
|
||||||
|
| Array - An array of allowed origins.
|
||||||
|
| String (*) - A wildcard (*) to allow all request origins.
|
||||||
|
| Function - Receives the current origin string and should return
|
||||||
|
| one of the above values.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
origin: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Methods
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| An array of allowed HTTP methods for CORS. The `Access-Control-Request-Method`
|
||||||
|
| is checked against the following list.
|
||||||
|
|
|
||||||
|
| Following is the list of default methods. Feel free to add more.
|
||||||
|
*/
|
||||||
|
methods: ['GET', 'HEAD', 'POST', 'PUT', 'DELETE'],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Headers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| List of headers to be allowed for `Access-Control-Allow-Headers` header.
|
||||||
|
| The value can be one of the following:
|
||||||
|
|
|
||||||
|
| https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Headers
|
||||||
|
|
|
||||||
|
| Boolean(true) - Allow all headers mentioned in `Access-Control-Request-Headers`.
|
||||||
|
| Boolean(false) - Disallow all headers.
|
||||||
|
| String - Comma separated list of allowed headers.
|
||||||
|
| Array - An array of allowed headers.
|
||||||
|
| Function - Receives the current header and should return one of the above values.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
headers: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Expose Headers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| A list of headers to be exposed by setting `Access-Control-Expose-Headers`.
|
||||||
|
| header. By default following 6 simple response headers are exposed.
|
||||||
|
|
|
||||||
|
| Cache-Control
|
||||||
|
| Content-Language
|
||||||
|
| Content-Type
|
||||||
|
| Expires
|
||||||
|
| Last-Modified
|
||||||
|
| Pragma
|
||||||
|
|
|
||||||
|
| In order to add more headers, simply define them inside the following array.
|
||||||
|
|
|
||||||
|
| https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
exposeHeaders: [
|
||||||
|
'cache-control',
|
||||||
|
'content-language',
|
||||||
|
'content-type',
|
||||||
|
'expires',
|
||||||
|
'last-modified',
|
||||||
|
'pragma',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Credentials
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Toggle `Access-Control-Allow-Credentials` header. If value is set to `true`,
|
||||||
|
| then header will be set, otherwise not.
|
||||||
|
|
|
||||||
|
| https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
credentials: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| MaxAge
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define `Access-Control-Max-Age` header in seconds.
|
||||||
|
| https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
maxAge: 90,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default corsConfig
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* Config source: https://git.io/JesV9
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this config
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
|
import type { DatabaseConfig } from '@ioc:Adonis/Lucid/Database'
|
||||||
|
|
||||||
|
const databaseConfig: DatabaseConfig = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Connection
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The primary connection for making database queries across the application
|
||||||
|
| You can use any key from the `connections` object defined in this same
|
||||||
|
| file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
connection: Env.get('DB_CONNECTION'),
|
||||||
|
|
||||||
|
connections: {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| MySQL config
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configuration for MySQL database. Make sure to install the driver
|
||||||
|
| from npm when using this connection
|
||||||
|
|
|
||||||
|
| npm i mysql2
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
mysql: {
|
||||||
|
client: 'mysql2',
|
||||||
|
connection: {
|
||||||
|
host: Env.get('MYSQL_HOST'),
|
||||||
|
port: Env.get('MYSQL_PORT'),
|
||||||
|
user: Env.get('MYSQL_USER'),
|
||||||
|
password: Env.get('MYSQL_PASSWORD', ''),
|
||||||
|
database: Env.get('MYSQL_DB_NAME'),
|
||||||
|
},
|
||||||
|
migrations: {
|
||||||
|
naturalSort: true,
|
||||||
|
},
|
||||||
|
healthCheck: false,
|
||||||
|
debug: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default databaseConfig
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
/**
|
||||||
|
* Config source: https://git.io/JBt3o
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this config
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
|
import { driveConfig } from '@adonisjs/core/build/config'
|
||||||
|
import Application from '@ioc:Adonis/Core/Application'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Drive Config
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The `DriveConfig` relies on the `DisksList` interface which is
|
||||||
|
| defined inside the `contracts` directory.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export default driveConfig({
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default disk
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The default disk to use for managing file uploads. The value is driven by
|
||||||
|
| the `DRIVE_DISK` environment variable.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
disk: Env.get('DRIVE_DISK'),
|
||||||
|
|
||||||
|
disks: {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Local
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Uses the local file system to manage files. Make sure to turn off serving
|
||||||
|
| files when not using this disk.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
local: {
|
||||||
|
driver: 'local',
|
||||||
|
visibility: 'public',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Storage root - Local driver only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define an absolute path to the storage directory from where to read the
|
||||||
|
| files.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
root: Application.tmpPath('uploads'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Serve files - Local driver only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When this is set to true, AdonisJS will configure a files server to serve
|
||||||
|
| files from the disk root. This is done to mimic the behavior of cloud
|
||||||
|
| storage services that has inbuilt capabilities to serve files.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
serveFiles: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Base path - Local driver only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Base path is always required when "serveFiles = true". Also make sure
|
||||||
|
| the `basePath` is unique across all the disks using "local" driver and
|
||||||
|
| you are not registering routes with this prefix.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
basePath: '/uploads',
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| S3 Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Uses the S3 cloud storage to manage files. Make sure to install the s3
|
||||||
|
| drive separately when using it.
|
||||||
|
|
|
||||||
|
|**************************************************************************
|
||||||
|
| npm i @adonisjs/drive-s3
|
||||||
|
|**************************************************************************
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
// s3: {
|
||||||
|
// driver: 's3',
|
||||||
|
// visibility: 'public',
|
||||||
|
// key: Env.get('S3_KEY'),
|
||||||
|
// secret: Env.get('S3_SECRET'),
|
||||||
|
// region: Env.get('S3_REGION'),
|
||||||
|
// bucket: Env.get('S3_BUCKET'),
|
||||||
|
// endpoint: Env.get('S3_ENDPOINT'),
|
||||||
|
//
|
||||||
|
// // For minio to work
|
||||||
|
// // forcePathStyle: true,
|
||||||
|
// },
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| GCS Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Uses the Google cloud storage to manage files. Make sure to install the GCS
|
||||||
|
| drive separately when using it.
|
||||||
|
|
|
||||||
|
|**************************************************************************
|
||||||
|
| npm i @adonisjs/drive-gcs
|
||||||
|
|**************************************************************************
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
// gcs: {
|
||||||
|
// driver: 'gcs',
|
||||||
|
// visibility: 'public',
|
||||||
|
// keyFilename: Env.get('GCS_KEY_FILENAME'),
|
||||||
|
// bucket: Env.get('GCS_BUCKET'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Uniform ACL - Google cloud storage only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the Uniform ACL on the bucket, the "visibility" option is
|
||||||
|
| ignored. Since, the files ACL is managed by the google bucket policies
|
||||||
|
| directly.
|
||||||
|
|
|
||||||
|
|**************************************************************************
|
||||||
|
| Learn more: https://cloud.google.com/storage/docs/uniform-bucket-level-access
|
||||||
|
|**************************************************************************
|
||||||
|
|
|
||||||
|
| The following option just informs drive whether your bucket is using uniform
|
||||||
|
| ACL or not. The actual setting needs to be toggled within the Google cloud
|
||||||
|
| console.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
// usingUniformAcl: false,
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
/**
|
||||||
|
* Config source: https://git.io/JfefW
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this config
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
|
import { hashConfig } from '@adonisjs/core/build/config'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Hash Config
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The `HashConfig` relies on the `HashList` interface which is
|
||||||
|
| defined inside `contracts` directory.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export default hashConfig({
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default hasher
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default we make use of the argon hasher to hash values. However, feel
|
||||||
|
| free to change the default value
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
default: Env.get('HASH_DRIVER', 'scrypt'),
|
||||||
|
|
||||||
|
list: {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| scrypt
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Scrypt mapping uses the Node.js inbuilt crypto module for creating
|
||||||
|
| hashes.
|
||||||
|
|
|
||||||
|
| We are using the default configuration recommended within the Node.js
|
||||||
|
| documentation.
|
||||||
|
| https://nodejs.org/api/crypto.html#cryptoscryptpassword-salt-keylen-options-callback
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
scrypt: {
|
||||||
|
driver: 'scrypt',
|
||||||
|
cost: 16384,
|
||||||
|
blockSize: 8,
|
||||||
|
parallelization: 1,
|
||||||
|
saltSize: 16,
|
||||||
|
keyLength: 64,
|
||||||
|
maxMemory: 32 * 1024 * 1024,
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Argon
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Argon mapping uses the `argon2` driver to hash values.
|
||||||
|
|
|
||||||
|
| Make sure you install the underlying dependency for this driver to work.
|
||||||
|
| https://www.npmjs.com/package/phc-argon2.
|
||||||
|
|
|
||||||
|
| npm install phc-argon2
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
argon: {
|
||||||
|
driver: 'argon2',
|
||||||
|
variant: 'id',
|
||||||
|
iterations: 3,
|
||||||
|
memory: 4096,
|
||||||
|
parallelism: 1,
|
||||||
|
saltSize: 16,
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Bcrypt
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Bcrypt mapping uses the `bcrypt` driver to hash values.
|
||||||
|
|
|
||||||
|
| Make sure you install the underlying dependency for this driver to work.
|
||||||
|
| https://www.npmjs.com/package/phc-bcrypt.
|
||||||
|
|
|
||||||
|
| npm install phc-bcrypt
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
bcrypt: {
|
||||||
|
driver: 'bcrypt',
|
||||||
|
rounds: 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
/**
|
||||||
|
* Contract source: https://git.io/JBt3I
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this contract
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { InferDisksFromConfig } from '@adonisjs/core/build/config'
|
||||||
|
import type driveConfig from '../config/drive'
|
||||||
|
|
||||||
|
declare module '@ioc:Adonis/Core/Drive' {
|
||||||
|
interface DisksList extends InferDisksFromConfig<typeof driveConfig> {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* Contract source: https://git.io/JTm6U
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this contract
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare module '@ioc:Adonis/Core/Env' {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Getting types for validated environment variables
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The `default` export from the "../env.ts" file exports types for the
|
||||||
|
| validated environment variables. Here we merge them with the `EnvTypes`
|
||||||
|
| interface so that you can enjoy intellisense when using the "Env"
|
||||||
|
| module.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
type CustomTypes = typeof import('../env').default
|
||||||
|
interface EnvTypes extends CustomTypes {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* Contract source: https://git.io/JfefG
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this contract
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare module '@ioc:Adonis/Core/Event' {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Define typed events
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You can define types for events inside the following interface and
|
||||||
|
| AdonisJS will make sure that all listeners and emit calls adheres
|
||||||
|
| to the defined types.
|
||||||
|
|
|
||||||
|
| For example:
|
||||||
|
|
|
||||||
|
| interface EventsList {
|
||||||
|
| 'new:user': UserModel
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| Now calling `Event.emit('new:user')` will statically ensure that passed value is
|
||||||
|
| an instance of the the UserModel only.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
interface EventsList {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
/**
|
||||||
|
* Contract source: https://git.io/Jfefs
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this contract
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { InferListFromConfig } from '@adonisjs/core/build/config'
|
||||||
|
import type hashConfig from '../config/hash'
|
||||||
|
|
||||||
|
declare module '@ioc:Adonis/Core/Hash' {
|
||||||
|
interface HashersList extends InferListFromConfig<typeof hashConfig> {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
/**
|
||||||
|
* Contract source: https://bit.ly/3DP1ypf
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this contract
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import '@japa/runner'
|
||||||
|
|
||||||
|
declare module '@japa/runner' {
|
||||||
|
interface TestContext {
|
||||||
|
// Extend context
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Test<TestData> {
|
||||||
|
// Extend test
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
// import Factory from '@ioc:Adonis/Lucid/Factory'
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import BaseSchema from "@ioc:Adonis/Lucid/Schema";
|
||||||
|
|
||||||
|
export default class extends BaseSchema {
|
||||||
|
protected tableName = "users";
|
||||||
|
|
||||||
|
public async up() {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments("id_user").primary();
|
||||||
|
|
||||||
|
table.string("username", 50).notNullable();
|
||||||
|
table.string("password", 300).notNullable();
|
||||||
|
table.timestamp("created_at", { useTz: true });
|
||||||
|
table.timestamp("updated_at", { useTz: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down() {
|
||||||
|
this.schema.dropTable(this.tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class extends BaseSchema {
|
||||||
|
protected tableName = 'key_values'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id_key').primary()
|
||||||
|
table.string("key", 100).notNullable()
|
||||||
|
table.string("value", 200).notNullable()
|
||||||
|
table.string("model", 30).notNullable().defaultTo("All")
|
||||||
|
/**
|
||||||
|
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||||
|
*/
|
||||||
|
table.timestamp('created_at', { useTz: true })
|
||||||
|
table.timestamp('updated_at', { useTz: true })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class extends BaseSchema {
|
||||||
|
protected tableName = 'log_detect_files'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id_ldf').primary()
|
||||||
|
table.string("file_name", 100).notNullable()
|
||||||
|
/**
|
||||||
|
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||||
|
*/
|
||||||
|
table.timestamp('created_at', { useTz: true })
|
||||||
|
table.timestamp('updated_at', { useTz: true })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class extends BaseSchema {
|
||||||
|
protected tableName = 'log_reports'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id_report').primary()
|
||||||
|
table.string("detected_content", 200).notNullable()
|
||||||
|
table.integer("line", 6).notNullable()
|
||||||
|
table.integer("id_file").notNullable()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||||
|
*/
|
||||||
|
table.timestamp('created_at', { useTz: true })
|
||||||
|
table.timestamp('updated_at', { useTz: true })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Validating Environment Variables
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| In this file we define the rules for validating environment variables.
|
||||||
|
| By performing validation we ensure that your application is running in
|
||||||
|
| a stable environment with correct configuration values.
|
||||||
|
|
|
||||||
|
| This file is read automatically by the framework during the boot lifecycle
|
||||||
|
| and hence do not rename or move this file to a different location.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Env from "@ioc:Adonis/Core/Env";
|
||||||
|
|
||||||
|
export default Env.rules({
|
||||||
|
HOST: Env.schema.string({ format: "host" }),
|
||||||
|
PORT: Env.schema.number(),
|
||||||
|
APP_KEY: Env.schema.string(),
|
||||||
|
APP_NAME: Env.schema.string(),
|
||||||
|
DRIVE_DISK: Env.schema.enum(["local"] as const),
|
||||||
|
NODE_ENV: Env.schema.enum(["development", "production", "test"] as const),
|
||||||
|
DB_CONNECTION: Env.schema.string(),
|
||||||
|
MYSQL_HOST: Env.schema.string({ format: "host" }),
|
||||||
|
MYSQL_PORT: Env.schema.number(),
|
||||||
|
MYSQL_USER: Env.schema.string(),
|
||||||
|
MYSQL_PASSWORD: Env.schema.string.optional(),
|
||||||
|
MYSQL_DB_NAME: Env.schema.string(),
|
||||||
|
});
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"name": "log-server",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "node ace serve --watch",
|
||||||
|
"build": "node ace build --production",
|
||||||
|
"start": "node server.js",
|
||||||
|
"test": "node ace test"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@adonisjs/assembler": "^5.9.5",
|
||||||
|
"@japa/preset-adonis": "^1.2.0",
|
||||||
|
"@japa/runner": "^2.5.1",
|
||||||
|
"@types/proxy-addr": "^2.0.0",
|
||||||
|
"@types/source-map-support": "^0.5.6",
|
||||||
|
"adonis-preset-ts": "^2.1.0",
|
||||||
|
"pino-pretty": "^10.2.0",
|
||||||
|
"typescript": "~4.6",
|
||||||
|
"youch": "^3.2.3",
|
||||||
|
"youch-terminal": "^2.2.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@adonisjs/core": "^5.9.0",
|
||||||
|
"@adonisjs/lucid": "^18.4.0",
|
||||||
|
"@adonisjs/repl": "^3.1.11",
|
||||||
|
"chokidar": "^3.5.3",
|
||||||
|
"fs": "^0.0.1-security",
|
||||||
|
"luxon": "^3.4.0",
|
||||||
|
"moment": "^2.29.4",
|
||||||
|
"mysql2": "^3.6.0",
|
||||||
|
"proxy-addr": "^2.0.7",
|
||||||
|
"reflect-metadata": "^0.1.13",
|
||||||
|
"source-map-support": "^0.5.21"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
import type { ApplicationContract } from '@ioc:Adonis/Core/Application'
|
||||||
|
|
||||||
|
export default class AppProvider {
|
||||||
|
constructor (protected app: ApplicationContract) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public register () {
|
||||||
|
// Register your own bindings
|
||||||
|
}
|
||||||
|
|
||||||
|
public async boot () {
|
||||||
|
// IoC container is ready
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ready () {
|
||||||
|
|
||||||
|
// App is ready
|
||||||
|
}
|
||||||
|
|
||||||
|
public async shutdown () {
|
||||||
|
// Cleanup, since app is going down
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| AdonisJs Server
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The contents in this file is meant to bootstrap the AdonisJs application
|
||||||
|
| and start the HTTP server to accept incoming connections. You must avoid
|
||||||
|
| making this file dirty and instead make use of `lifecycle hooks` provided
|
||||||
|
| by AdonisJs service providers for custom code.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
import 'reflect-metadata'
|
||||||
|
import sourceMapSupport from 'source-map-support'
|
||||||
|
import { Ignitor } from '@adonisjs/core/build/standalone'
|
||||||
|
|
||||||
|
sourceMapSupport.install({ handleUncaughtExceptions: false })
|
||||||
|
|
||||||
|
new Ignitor(__dirname)
|
||||||
|
.httpServer()
|
||||||
|
.start()
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This file is used to define middleware for HTTP requests. You can register
|
||||||
|
| middleware as a `closure` or an IoC container binding. The bindings are
|
||||||
|
| preferred, since they keep this file clean.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Server from '@ioc:Adonis/Core/Server'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Global middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| An array of global middleware, that will be executed in the order they
|
||||||
|
| are defined for every HTTP requests.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Server.middleware.register([
|
||||||
|
() => import('@ioc:Adonis/Core/BodyParser'),
|
||||||
|
])
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Named middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Named middleware are defined as key-value pair. The value is the namespace
|
||||||
|
| or middleware function and key is the alias. Later you can use these
|
||||||
|
| alias on individual routes. For example:
|
||||||
|
|
|
||||||
|
| { auth: () => import('App/Middleware/Auth') }
|
||||||
|
|
|
||||||
|
| and then use it as follows
|
||||||
|
|
|
||||||
|
| Route.get('dashboard', 'UserController.dashboard').middleware('auth')
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Server.middleware.registerNamed({
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This file is dedicated for defining HTTP routes. A single file is enough
|
||||||
|
| for majority of projects, however you can define routes in different
|
||||||
|
| files and just make sure to import them inside this file. For example
|
||||||
|
|
|
||||||
|
| Define routes in following two files
|
||||||
|
| ├── start/routes/cart.ts
|
||||||
|
| ├── start/routes/customer.ts
|
||||||
|
|
|
||||||
|
| and then import them inside `start/routes.ts` as follows
|
||||||
|
|
|
||||||
|
| import './routes/cart'
|
||||||
|
| import './routes/customer'
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Route from '@ioc:Adonis/Core/Route'
|
||||||
|
import LogDetectFile from 'App/Models/LogDetectFile'
|
||||||
|
import { runtimeCheckLogs } from 'App/Exceptions/utils/runtimeCheckLogs'
|
||||||
|
import Env from '@ioc:Adonis/Core/Env';
|
||||||
|
|
||||||
|
runtimeCheckLogs(Env.get("FOLDER_LOGS"))
|
||||||
|
|
||||||
|
Route.get('/', async () => {
|
||||||
|
// const a = await LogDetectFile.all()
|
||||||
|
console.log("first")
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Tests
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The contents in this file boots the AdonisJS application and configures
|
||||||
|
| the Japa tests runner.
|
||||||
|
|
|
||||||
|
| For the most part you will never edit this file. The configuration
|
||||||
|
| for the tests can be controlled via ".adonisrc.json" and
|
||||||
|
| "tests/bootstrap.ts" files.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
process.env.NODE_ENV = 'test'
|
||||||
|
|
||||||
|
import 'reflect-metadata'
|
||||||
|
import sourceMapSupport from 'source-map-support'
|
||||||
|
import { Ignitor } from '@adonisjs/core/build/standalone'
|
||||||
|
import { configure, processCliArgs, run, RunnerHooksHandler } from '@japa/runner'
|
||||||
|
|
||||||
|
sourceMapSupport.install({ handleUncaughtExceptions: false })
|
||||||
|
|
||||||
|
const kernel = new Ignitor(__dirname).kernel('test')
|
||||||
|
|
||||||
|
kernel
|
||||||
|
.boot()
|
||||||
|
.then(() => import('./tests/bootstrap'))
|
||||||
|
.then(({ runnerHooks, ...config }) => {
|
||||||
|
const app: RunnerHooksHandler[] = [() => kernel.start()]
|
||||||
|
|
||||||
|
configure({
|
||||||
|
...kernel.application.rcFile.tests,
|
||||||
|
...processCliArgs(process.argv.slice(2)),
|
||||||
|
...config,
|
||||||
|
...{
|
||||||
|
importer: (filePath) => import(filePath),
|
||||||
|
setup: app.concat(runnerHooks.setup),
|
||||||
|
teardown: runnerHooks.teardown,
|
||||||
|
},
|
||||||
|
cwd: kernel.application.appRoot
|
||||||
|
})
|
||||||
|
|
||||||
|
run()
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
* File source: https://bit.ly/3ukaHTz
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this contract
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { Config } from '@japa/runner'
|
||||||
|
import TestUtils from '@ioc:Adonis/Core/TestUtils'
|
||||||
|
import { assert, runFailedTests, specReporter, apiClient } from '@japa/preset-adonis'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Japa Plugins
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Japa plugins allows you to add additional features to Japa. By default
|
||||||
|
| we register the assertion plugin.
|
||||||
|
|
|
||||||
|
| Feel free to remove existing plugins or add more.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const plugins: Required<Config>['plugins'] = [assert(), runFailedTests(), apiClient()]
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Japa Reporters
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Japa reporters displays/saves the progress of tests as they are executed.
|
||||||
|
| By default, we register the spec reporter to show a detailed report
|
||||||
|
| of tests on the terminal.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const reporters: Required<Config>['reporters'] = [specReporter()]
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Runner hooks
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Runner hooks are executed after booting the AdonisJS app and
|
||||||
|
| before the test files are imported.
|
||||||
|
|
|
||||||
|
| You can perform actions like starting the HTTP server or running migrations
|
||||||
|
| within the runner hooks
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const runnerHooks: Pick<Required<Config>, 'setup' | 'teardown'> = {
|
||||||
|
setup: [() => TestUtils.ace().loadCommands()],
|
||||||
|
teardown: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Configure individual suites
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The configureSuite method gets called for every test suite registered
|
||||||
|
| within ".adonisrc.json" file.
|
||||||
|
|
|
||||||
|
| You can use this method to configure suites. For example: Only start
|
||||||
|
| the HTTP server when it is a functional suite.
|
||||||
|
*/
|
||||||
|
export const configureSuite: Required<Config>['configureSuite'] = (suite) => {
|
||||||
|
if (suite.name === 'functional') {
|
||||||
|
suite.setup(() => TestUtils.httpServer().start())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { test } from '@japa/runner'
|
||||||
|
|
||||||
|
test('display welcome page', async ({ client }) => {
|
||||||
|
const response = await client.get('/')
|
||||||
|
|
||||||
|
response.assertStatus(200)
|
||||||
|
response.assertBodyContains({ hello: 'world' })
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"extends": "adonis-preset-ts/tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"build"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "build",
|
||||||
|
"rootDir": "./",
|
||||||
|
"sourceMap": true,
|
||||||
|
"paths": {
|
||||||
|
"App/*": [
|
||||||
|
"./app/*"
|
||||||
|
],
|
||||||
|
"Config/*": [
|
||||||
|
"./config/*"
|
||||||
|
],
|
||||||
|
"Contracts/*": [
|
||||||
|
"./contracts/*"
|
||||||
|
],
|
||||||
|
"Database/*": [
|
||||||
|
"./database/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"types": [
|
||||||
|
"@adonisjs/core",
|
||||||
|
"@adonisjs/repl",
|
||||||
|
"@japa/preset-adonis/build/adonis-typings",
|
||||||
|
"@adonisjs/lucid"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue