initial commit
This commit is contained in:
16
ace
Normal file
16
ace
Normal file
@@ -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))
|
||||||
123
ace-manifest.json
Normal file
123
ace-manifest.json
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
"ssr:build": {
|
||||||
|
"settings": {
|
||||||
|
"stayAlive": true
|
||||||
|
},
|
||||||
|
"commandPath": "@eidellev/inertia-adonisjs/build/commands/Build",
|
||||||
|
"commandName": "ssr:build",
|
||||||
|
"description": "Build and watch files for changes",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": []
|
||||||
|
},
|
||||||
|
"ssr:watch": {
|
||||||
|
"settings": {
|
||||||
|
"stayAlive": true
|
||||||
|
},
|
||||||
|
"commandPath": "@eidellev/inertia-adonisjs/build/commands/Watch",
|
||||||
|
"commandName": "ssr:watch",
|
||||||
|
"description": "Build and watch files for changes",
|
||||||
|
"args": [],
|
||||||
|
"aliases": [],
|
||||||
|
"flags": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"aliases": {}
|
||||||
|
}
|
||||||
29
app/Exceptions/Handler.ts
Normal file
29
app/Exceptions/Handler.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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 {
|
||||||
|
protected statusPages = {
|
||||||
|
'403': 'errors/unauthorized',
|
||||||
|
'404': 'errors/not-found',
|
||||||
|
'500..599': 'errors/server-error',
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(Logger)
|
||||||
|
}
|
||||||
|
}
|
||||||
19
commands/index.ts
Normal file
19
commands/index.ts
Normal file
@@ -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'])
|
||||||
276
config/app.ts
Normal file
276
config/app.ts
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
/**
|
||||||
|
* 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 Application from '@ioc:Adonis/Core/Application'
|
||||||
|
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'
|
||||||
|
import type { AssetsManagerConfig } from '@ioc:Adonis/Core/AssetsManager'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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 = {}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Assets
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure the asset manager you are using to compile the frontend assets
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const assets: AssetsManagerConfig = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Currently we only support webpack encore and may introduce more drivers
|
||||||
|
| in the future
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
driver: Env.get('ASSETS_DRIVER'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Public path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Directory to search for the "manifest.json" and the "entrypoints.json"
|
||||||
|
| files
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
publicPath: Application.publicPath('assets'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Script tag
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define attributes for the entryPointScripts tags
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
script: {
|
||||||
|
attributes: {
|
||||||
|
defer: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Style tag
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define attributes for the entryPointStyles tags
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
style: {
|
||||||
|
attributes: {},
|
||||||
|
},
|
||||||
|
}
|
||||||
205
config/bodyparser.ts
Normal file
205
config/bodyparser.ts
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
/**
|
||||||
|
* 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
|
||||||
134
config/cors.ts
Normal file
134
config/cors.ts
Normal file
@@ -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
|
||||||
149
config/drive.ts
Normal file
149
config/drive.ts
Normal file
@@ -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,
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
})
|
||||||
96
config/hash.ts
Normal file
96
config/hash.ts
Normal file
@@ -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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
20
config/inertia.ts
Normal file
20
config/inertia.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Feel free to let me know via PR,
|
||||||
|
* if you find something broken in this config file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { InertiaConfig } from '@ioc:EidelLev/Inertia';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Inertia-AdonisJS config
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const inertia: InertiaConfig = {
|
||||||
|
view: 'app',
|
||||||
|
ssr: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
116
config/session.ts
Normal file
116
config/session.ts
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
/**
|
||||||
|
* Config source: https://git.io/JeYHp
|
||||||
|
*
|
||||||
|
* 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 Application from '@ioc:Adonis/Core/Application'
|
||||||
|
import { sessionConfig } from '@adonisjs/session/build/config'
|
||||||
|
|
||||||
|
export default sessionConfig({
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable/Disable sessions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting the following property to "false" will disable the session for the
|
||||||
|
| entire application
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
enabled: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The session driver to use. You can choose between one of the following
|
||||||
|
| drivers.
|
||||||
|
|
|
||||||
|
| - cookie (Uses signed cookies to store session values)
|
||||||
|
| - file (Uses filesystem to store session values)
|
||||||
|
| - redis (Uses redis. Make sure to install "@adonisjs/redis" as well)
|
||||||
|
|
|
||||||
|
| Note: Switching drivers will make existing sessions invalid.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
driver: Env.get('SESSION_DRIVER'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cookie name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The name of the cookie that will hold the session id.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
cookieName: 'adonis-session',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Clear session when browser closes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Whether or not you want to destroy the session when browser closes. Setting
|
||||||
|
| this value to `true` will ignore the `age`.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
clearWithBrowser: false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session age
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The duration for which session stays active after no activity. A new HTTP
|
||||||
|
| request to the server is considered as activity.
|
||||||
|
|
|
||||||
|
| The value can be a number in milliseconds or a string that must be valid
|
||||||
|
| as per https://npmjs.org/package/ms package.
|
||||||
|
|
|
||||||
|
| Example: `2 days`, `2.5 hrs`, `1y`, `5s` and so on.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
age: '2h',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cookie values
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The cookie settings are used to setup the session id cookie and also the
|
||||||
|
| driver will use the same values.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
cookie: {
|
||||||
|
path: '/',
|
||||||
|
httpOnly: true,
|
||||||
|
sameSite: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Configuration for the file driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The file driver needs absolute path to the directory in which sessions
|
||||||
|
| must be stored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
file: {
|
||||||
|
location: Application.tmpPath('sessions'),
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Redis driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The redis connection you want session driver to use. The same connection
|
||||||
|
| must be defined inside `config/redis.ts` file as well.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
redisConnection: 'local',
|
||||||
|
})
|
||||||
236
config/shield.ts
Normal file
236
config/shield.ts
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
/**
|
||||||
|
* Config source: https://git.io/Jvwvt
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this config
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { ShieldConfig } from '@ioc:Adonis/Addons/Shield'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Content Security Policy
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Content security policy filters out the origins not allowed to execute
|
||||||
|
| and load resources like scripts, styles and fonts. There are wide
|
||||||
|
| variety of options to choose from.
|
||||||
|
*/
|
||||||
|
export const csp: ShieldConfig['csp'] = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable/disable CSP
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The CSP rules are disabled by default for seamless onboarding.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
enabled: false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Directives
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| All directives are defined in camelCase and here is the list of
|
||||||
|
| available directives and their possible values.
|
||||||
|
|
|
||||||
|
| https://content-security-policy.com
|
||||||
|
|
|
||||||
|
| @example
|
||||||
|
| directives: {
|
||||||
|
| defaultSrc: ["'self'", '@nonce', 'cdnjs.cloudflare.com']
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
directives: {},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Report only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting `reportOnly=true` will not block the scripts from running and
|
||||||
|
| instead report them to a URL.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
reportOnly: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| CSRF Protection
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| CSRF Protection adds another layer of security by making sure, actionable
|
||||||
|
| routes does have a valid token to execute an action.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const csrf: ShieldConfig['csrf'] = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable/Disable CSRF
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
enabled: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Routes to Ignore
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define an array of route patterns that you want to ignore from CSRF
|
||||||
|
| validation. Make sure the route patterns are started with a leading
|
||||||
|
| slash. Example:
|
||||||
|
|
|
||||||
|
| `/foo/bar`
|
||||||
|
|
|
||||||
|
| Also you can define a function that is evaluated on every HTTP Request.
|
||||||
|
| ```
|
||||||
|
| exceptRoutes: ({ request }) => request.url().includes('/api')
|
||||||
|
| ```
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
exceptRoutes: [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable Sharing Token Via Cookie
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When the following flag is enabled, AdonisJS will drop `XSRF-TOKEN`
|
||||||
|
| cookie that frontend frameworks can read and return back as a
|
||||||
|
| `X-XSRF-TOKEN` header.
|
||||||
|
|
|
||||||
|
| The cookie has `httpOnly` flag set to false, so it is little insecure and
|
||||||
|
| can be turned off when you are not using a frontend framework making
|
||||||
|
| AJAX requests.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
enableXsrfCookie: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Methods to Validate
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define an array of HTTP methods to be validated for a valid CSRF token.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
methods: ['POST', 'PUT', 'PATCH', 'DELETE'],
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| DNS Prefetching
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| DNS prefetching allows browsers to proactively perform domain name
|
||||||
|
| resolution in background.
|
||||||
|
|
|
||||||
|
| Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const dnsPrefetch: ShieldConfig['dnsPrefetch'] = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable/disable this feature
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
enabled: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Allow or Dis-Allow Explicitly
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The `enabled` boolean does not set `X-DNS-Prefetch-Control` header. However
|
||||||
|
| the `allow` boolean controls the value of `X-DNS-Prefetch-Control` header.
|
||||||
|
|
|
||||||
|
| - When `allow = true`, then `X-DNS-Prefetch-Control = 'on'`
|
||||||
|
| - When `allow = false`, then `X-DNS-Prefetch-Control = 'off'`
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
allow: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Iframe Options
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| xFrame defines whether or not your website can be embedded inside an
|
||||||
|
| iframe. Choose from one of the following options.
|
||||||
|
|
|
||||||
|
| - DENY
|
||||||
|
| - SAMEORIGIN
|
||||||
|
| - ALLOW-FROM http://example.com
|
||||||
|
|
|
||||||
|
| Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
|
||||||
|
*/
|
||||||
|
export const xFrame: ShieldConfig['xFrame'] = {
|
||||||
|
enabled: true,
|
||||||
|
action: 'DENY',
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Http Strict Transport Security
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| A security to ensure that a browser always makes a connection over
|
||||||
|
| HTTPS.
|
||||||
|
|
|
||||||
|
| Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const hsts: ShieldConfig['hsts'] = {
|
||||||
|
enabled: true,
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Max Age
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Control, how long the browser should remember that a site is only to be
|
||||||
|
| accessed using HTTPS.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
maxAge: '180 days',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Include Subdomains
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Apply rules on the subdomains as well.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
includeSubDomains: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Preloading
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Google maintains a service to register your domain and it will preload
|
||||||
|
| the HSTS policy. Learn more https://hstspreload.org/
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
preload: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| No Sniff
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Browsers have a habit of sniffing content-type of a response. Which means
|
||||||
|
| files with .txt extension containing Javascript code will be executed as
|
||||||
|
| Javascript. You can disable this behavior by setting nosniff to false.
|
||||||
|
|
|
||||||
|
| Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
export const contentTypeSniffing: ShieldConfig['contentTypeSniffing'] = {
|
||||||
|
enabled: true,
|
||||||
|
}
|
||||||
89
config/static.ts
Normal file
89
config/static.ts
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* Config source: https://git.io/Jfefl
|
||||||
|
*
|
||||||
|
* Feel free to let us know via PR, if you find something broken in this config
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { AssetsConfig } from '@ioc:Adonis/Core/Static'
|
||||||
|
|
||||||
|
const staticConfig: AssetsConfig = {
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enabled
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| A boolean to enable or disable serving static files. The static files
|
||||||
|
| are served from the `public` directory inside the application root.
|
||||||
|
| However, you can override the default path inside `.adonisrc.json`
|
||||||
|
| file.
|
||||||
|
|
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
enabled: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Handling Dot Files
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Decide how you want the static assets server to handle the `dotfiles`.
|
||||||
|
| By default, we ignore them as if they don't exists. However, you
|
||||||
|
| can choose between one of the following options.
|
||||||
|
|
|
||||||
|
| - ignore: Behave as if the file doesn't exists. Results in 404.
|
||||||
|
| - deny: Deny access to the file. Results in 403.
|
||||||
|
| - allow: Serve the file contents
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
dotFiles: 'ignore',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Generating Etag
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Handle whether or not to generate etags for the files. Etag allows browser
|
||||||
|
| to utilize the cache when file hasn't been changed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
etag: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Set Last Modified
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Whether or not to set the `Last-Modified` header in the response. Uses
|
||||||
|
| the file system's last modified value.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
lastModified: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Max age
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Set the value for the max-age directive. Set a higher value in production
|
||||||
|
| if you fingerprint your assets.
|
||||||
|
|
|
||||||
|
| Learn more: https://docs.adonisjs.com/guides/deployment#serving-static-assets
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
maxAge: 0,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Immutable
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Set the immutable directive. Set it to `true` if the assets are generated
|
||||||
|
| with a fingerprint. In others words the file name changes when the file
|
||||||
|
| contents change.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
immutable: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default staticConfig
|
||||||
13
contracts/drive.ts
Normal file
13
contracts/drive.ts
Normal file
@@ -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> {}
|
||||||
|
}
|
||||||
23
contracts/env.ts
Normal file
23
contracts/env.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* 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 {}
|
||||||
|
}
|
||||||
31
contracts/events.ts
Normal file
31
contracts/events.ts
Normal file
@@ -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 {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
13
contracts/hash.ts
Normal file
13
contracts/hash.ts
Normal file
@@ -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> {}
|
||||||
|
}
|
||||||
18
contracts/tests.ts
Normal file
18
contracts/tests.ts
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
26
env.ts
Normal file
26
env.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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(),
|
||||||
|
CACHE_VIEWS: Env.schema.boolean(),
|
||||||
|
SESSION_DRIVER: Env.schema.string(),
|
||||||
|
DRIVE_DISK: Env.schema.enum(['local'] as const),
|
||||||
|
NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const),
|
||||||
|
})
|
||||||
27631
package-lock.json
generated
Normal file
27631
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
81
package.json
Normal file
81
package.json
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"name": "enzos-events",
|
||||||
|
"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",
|
||||||
|
"lint": "eslint . --ext=.ts",
|
||||||
|
"format": "prettier --write ."
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": [
|
||||||
|
"plugin:adonis/typescriptApp",
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"prettier/prettier": [
|
||||||
|
"error"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eslintIgnore": [
|
||||||
|
"build"
|
||||||
|
],
|
||||||
|
"prettier": {
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"useTabs": false,
|
||||||
|
"quoteProps": "consistent",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"printWidth": 100
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@adonisjs/assembler": "^5.9.5",
|
||||||
|
"@babel/core": "^7.22.5",
|
||||||
|
"@babel/preset-env": "^7.22.5",
|
||||||
|
"@japa/preset-adonis": "^1.2.0",
|
||||||
|
"@japa/runner": "^2.5.1",
|
||||||
|
"@symfony/webpack-encore": "^4.1.1",
|
||||||
|
"@types/proxy-addr": "^2.0.0",
|
||||||
|
"@types/source-map-support": "^0.5.6",
|
||||||
|
"@vicons/material": "^0.12.0",
|
||||||
|
"adonis-preset-ts": "^2.1.0",
|
||||||
|
"eslint": "^8.43.0",
|
||||||
|
"eslint-config-prettier": "^8.8.0",
|
||||||
|
"eslint-plugin-adonis": "^2.1.1",
|
||||||
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
|
"naive-ui": "^2.34.4",
|
||||||
|
"pino-pretty": "^10.0.0",
|
||||||
|
"postcss-loader": "^7.3.3",
|
||||||
|
"prettier": "^2.8.8",
|
||||||
|
"tailwindcss": "^3.3.2",
|
||||||
|
"typescript": "~4.6",
|
||||||
|
"unplugin-vue-components": "^0.25.1",
|
||||||
|
"vue-loader": "^17.2.2",
|
||||||
|
"webpack": "^5.88.1",
|
||||||
|
"webpack-cli": "^4.10.0",
|
||||||
|
"youch": "^3.2.3",
|
||||||
|
"youch-terminal": "^2.2.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@adonisjs/core": "^5.9.0",
|
||||||
|
"@adonisjs/repl": "^3.1.11",
|
||||||
|
"@adonisjs/session": "^6.4.0",
|
||||||
|
"@adonisjs/shield": "^7.1.1",
|
||||||
|
"@adonisjs/view": "^6.2.0",
|
||||||
|
"@eidellev/inertia-adonisjs": "^8.0.1",
|
||||||
|
"@inertiajs/vue3": "^1.0.9",
|
||||||
|
"proxy-addr": "^2.0.7",
|
||||||
|
"reflect-metadata": "^0.1.13",
|
||||||
|
"source-map-support": "^0.5.21",
|
||||||
|
"vue": "^3.3.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
6
postcss.config.js
Normal file
6
postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
require('tailwindcss')()
|
||||||
|
]
|
||||||
|
}
|
||||||
21
providers/AppProvider.ts
Normal file
21
providers/AppProvider.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
12
public/assets/entrypoints.json
Normal file
12
public/assets/entrypoints.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"entrypoints": {
|
||||||
|
"app": {
|
||||||
|
"css": [
|
||||||
|
"http://localhost:8080/assets/app.css"
|
||||||
|
],
|
||||||
|
"js": [
|
||||||
|
"http://localhost:8080/assets/app.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
public/assets/manifest.json
Normal file
4
public/assets/manifest.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"assets/app.css": "http://localhost:8080/assets/app.css",
|
||||||
|
"assets/app.js": "http://localhost:8080/assets/app.js"
|
||||||
|
}
|
||||||
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
3
resources/css/app.css
Normal file
3
resources/css/app.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
14
resources/js/app.js
Normal file
14
resources/js/app.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import '../css/app.css'
|
||||||
|
import { createApp, h } from "vue";
|
||||||
|
import { createInertiaApp, Link } from "@inertiajs/vue3";
|
||||||
|
import '../css/app.css'
|
||||||
|
|
||||||
|
createInertiaApp({
|
||||||
|
resolve: (name) => require(`./pages/${name}`),
|
||||||
|
setup({ el, App, props, plugin }) {
|
||||||
|
createApp({ render: () => h(App, props) })
|
||||||
|
.use(plugin)
|
||||||
|
.component('inertia-link', Link)
|
||||||
|
.mount(el);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
resources/js/pages/Home.vue
Normal file
11
resources/js/pages/Home.vue
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<template>
|
||||||
|
{{ test }}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
test: String,
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
17
resources/views/app.edge
Normal file
17
resources/views/app.edge
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="icon" type="image/png" href="/favicon.ico">
|
||||||
|
|
||||||
|
@entryPointStyles('app')
|
||||||
|
@entryPointScripts('app')
|
||||||
|
|
||||||
|
<title>enzos-events</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
@inertia
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
1
resources/views/errors/not-found.edge
Normal file
1
resources/views/errors/not-found.edge
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<p> It's a 404 </p>
|
||||||
1
resources/views/errors/server-error.edge
Normal file
1
resources/views/errors/server-error.edge
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<p> It's a 500 </p>
|
||||||
1
resources/views/errors/unauthorized.edge
Normal file
1
resources/views/errors/unauthorized.edge
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<p> It's a 403 </p>
|
||||||
35
resources/views/welcome.edge
Normal file
35
resources/views/welcome.edge
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>AdonisJS - A fully featured web framework for Node.js</title>
|
||||||
|
@entryPointStyles('app')
|
||||||
|
@entryPointScripts('app')
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<div>
|
||||||
|
<h1 class="title"> It Works! </h1>
|
||||||
|
<p class="subtitle">
|
||||||
|
Congratulations, you have just created your first AdonisJS app.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
The route for this page is defined inside <code>start/routes.ts</code> file
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
You can update this page by editing <code>resources/views/welcome.edge</code> file
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
If you run into problems, you can reach us on <a href="https://discord.gg/vDcEjq6?">Discord</a> or the <a href="https://forum.adonisjs.com/">Forum</a>.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
19
server.ts
Normal file
19
server.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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()
|
||||||
17
start/inertia.ts
Normal file
17
start/inertia.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Inertia Preloaded File
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Any code written inside this file will be executed during the application
|
||||||
|
| boot.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Inertia from '@ioc:EidelLev/Inertia';
|
||||||
|
|
||||||
|
Inertia.share({
|
||||||
|
errors: (ctx) => {
|
||||||
|
return ctx.session.flashMessages.get('errors');
|
||||||
|
},
|
||||||
|
}).version(() => Inertia.manifestFile('public/assets/manifest.json'));
|
||||||
44
start/kernel.ts
Normal file
44
start/kernel.ts
Normal file
@@ -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'),
|
||||||
|
() => import('@ioc:EidelLev/Inertia/Middleware'),
|
||||||
|
])
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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({})
|
||||||
25
start/routes.ts
Normal file
25
start/routes.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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'
|
||||||
|
|
||||||
|
Route.get('/', async ({ inertia }) => {
|
||||||
|
return inertia.render('Home')
|
||||||
|
})
|
||||||
9
tailwind.config.js
Normal file
9
tailwind.config.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: ["./resources/**/*.{edge,js,ts,vue,jsx,tsx}"],
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
||||||
45
test.ts
Normal file
45
test.ts
Normal file
@@ -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()
|
||||||
|
})
|
||||||
69
tests/bootstrap.ts
Normal file
69
tests/bootstrap.ts
Normal file
@@ -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())
|
||||||
|
}
|
||||||
|
}
|
||||||
8
tests/functional/hello_world.spec.ts
Normal file
8
tests/functional/hello_world.spec.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { test } from '@japa/runner'
|
||||||
|
|
||||||
|
test('display welcome page', async ({ client }) => {
|
||||||
|
const response = await client.get('/')
|
||||||
|
|
||||||
|
response.assertStatus(200)
|
||||||
|
response.assertTextIncludes('<h1 class="title"> It Works! </h1>')
|
||||||
|
})
|
||||||
39
tsconfig.json
Normal file
39
tsconfig.json
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"extends": "adonis-preset-ts/tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"build"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"outDir": "build",
|
||||||
|
"rootDir": "./",
|
||||||
|
"sourceMap": true,
|
||||||
|
"paths": {
|
||||||
|
"App/*": [
|
||||||
|
"./app/*"
|
||||||
|
],
|
||||||
|
"Config/*": [
|
||||||
|
"./config/*"
|
||||||
|
],
|
||||||
|
"Contracts/*": [
|
||||||
|
"./contracts/*"
|
||||||
|
],
|
||||||
|
"Database/*": [
|
||||||
|
"./database/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"types": [
|
||||||
|
"@adonisjs/core",
|
||||||
|
"@adonisjs/repl",
|
||||||
|
"@adonisjs/session",
|
||||||
|
"@adonisjs/view",
|
||||||
|
"@adonisjs/shield",
|
||||||
|
"@japa/preset-adonis/build/adonis-typings",
|
||||||
|
"@eidellev/inertia-adonisjs"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
224
webpack.config.js
Normal file
224
webpack.config.js
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
const { join, resolve } = require('path')
|
||||||
|
const Encore = require('@symfony/webpack-encore')
|
||||||
|
const Components = require('unplugin-vue-components/webpack')
|
||||||
|
const { NaiveUiResolver } = require('unplugin-vue-components/resolvers')
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encore runtime environment
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
if (!Encore.isRuntimeEnvironmentConfigured()) {
|
||||||
|
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev')
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Output path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The output path for writing the compiled files. It should always
|
||||||
|
| be inside the public directory, so that AdonisJS can serve it.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.setOutputPath('./public/assets')
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Public URI
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The public URI to access the static files. It should always be
|
||||||
|
| relative from the "public" directory.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.setPublicPath('/assets')
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Entrypoints
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Entrypoints are script files that boots your frontend application. Ideally
|
||||||
|
| a single entrypoint is used by majority of applications. However, feel
|
||||||
|
| free to add more (if required).
|
||||||
|
|
|
||||||
|
| Also, make sure to read the docs on "Assets bundler" to learn more about
|
||||||
|
| entrypoints.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.addEntry('app', './resources/js/app.js')
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Copy assets
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Since the edge templates are not part of the Webpack compile lifecycle, any
|
||||||
|
| images referenced by it will not be processed by Webpack automatically. Hence
|
||||||
|
| we must copy them manually.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
// Encore.copyFiles({
|
||||||
|
// from: './resources/images',
|
||||||
|
// to: 'images/[path][name].[hash:8].[ext]',
|
||||||
|
// })
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Split shared code
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Instead of bundling duplicate code in all the bundles, generate a separate
|
||||||
|
| bundle for the shared code.
|
||||||
|
|
|
||||||
|
| https://symfony.com/doc/current/frontend/encore/split-chunks.html
|
||||||
|
| https://webpack.js.org/plugins/split-chunks-plugin/
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
// Encore.splitEntryChunks()
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Isolated entrypoints
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Treat each entry point and its dependencies as its own isolated module.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.disableSingleRuntimeChunk()
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cleanup output folder
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| It is always nice to cleanup the build output before creating a build. It
|
||||||
|
| will ensure that all unused files from the previous build are removed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.cleanupOutputBeforeBuild()
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Source maps
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Enable source maps in production
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.enableSourceMaps(!Encore.isProduction())
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Assets versioning
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Enable assets versioning to leverage lifetime browser and CDN cache
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.enableVersioning(Encore.isProduction())
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Configure dev server
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here we configure the dev server to enable live reloading for edge templates.
|
||||||
|
| Remember edge templates are not processed by Webpack and hence we need
|
||||||
|
| to watch them explicitly and livereload the browser.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.configureDevServerOptions((options) => {
|
||||||
|
/**
|
||||||
|
* Normalize "options.static" property to an array
|
||||||
|
*/
|
||||||
|
if (!options.static) {
|
||||||
|
options.static = []
|
||||||
|
} else if (!Array.isArray(options.static)) {
|
||||||
|
options.static = [options.static]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable live reload and add views directory
|
||||||
|
*/
|
||||||
|
options.liveReload = true
|
||||||
|
options.static.push({
|
||||||
|
directory: join(__dirname, './resources/views'),
|
||||||
|
watch: true,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| CSS precompilers support
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Uncomment one of the following lines of code to enable support for your
|
||||||
|
| favorite CSS precompiler
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
// Encore.enableSassLoader()
|
||||||
|
// Encore.enableLessLoader()
|
||||||
|
// Encore.enableStylusLoader()
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| CSS loaders
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Uncomment one of the following line of code to enable support for
|
||||||
|
| PostCSS or CSS.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.enablePostCssLoader()
|
||||||
|
// Encore.configureCssLoader(() => {})
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable Vue loader
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Uncomment the following lines of code to enable support for vue. Also make
|
||||||
|
| sure to install the required dependencies.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Encore.enableVueLoader(() => {}, {
|
||||||
|
version: 3,
|
||||||
|
runtimeCompilerBuild: false,
|
||||||
|
useJsx: false
|
||||||
|
})
|
||||||
|
|
||||||
|
Encore.addPlugin( Components({
|
||||||
|
resolvers: [NaiveUiResolver()]
|
||||||
|
}))
|
||||||
|
|
||||||
|
Encore.addAliases({
|
||||||
|
'@': resolve(__dirname, 'resources/js')
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Configure logging
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| To keep the terminal clean from unnecessary info statements , we only
|
||||||
|
| log warnings and errors. If you want all the logs, you can change
|
||||||
|
| the level to "info".
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
const config = Encore.getWebpackConfig()
|
||||||
|
config.infrastructureLogging = {
|
||||||
|
level: 'warn',
|
||||||
|
}
|
||||||
|
config.stats = 'errors-warnings'
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Export config
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Export config for webpack to do its job
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
module.exports = config
|
||||||
Reference in New Issue
Block a user