diff --git a/.idea/artclick.iml b/.idea/artclick.iml
deleted file mode 100644
index 0c8867d..0000000
--- a/.idea/artclick.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 23f6a13..01595f9 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/ace-manifest.json b/ace-manifest.json
index 1714018..48f6f56 100644
--- a/ace-manifest.json
+++ b/ace-manifest.json
@@ -1 +1,267 @@
-{"dump:rcfile":{"settings":{},"commandPath":"@adonisjs/core/build/commands/DumpRc","commandName":"dump:rcfile","description":"Dump contents of .adonisrc.json file along with defaults","args":[],"flags":[]},"list:routes":{"settings":{"loadApp":true},"commandPath":"@adonisjs/core/build/commands/ListRoutes","commandName":"list:routes","description":"List application routes","args":[],"flags":[{"name":"json","propertyName":"json","type":"boolean","description":"Output as JSON"}]},"generate:key":{"settings":{},"commandPath":"@adonisjs/core/build/commands/GenerateKey","commandName":"generate:key","description":"Generate a new APP_KEY secret","args":[],"flags":[]},"repl":{"settings":{"loadApp":true,"environment":"repl","stayAlive":true},"commandPath":"@adonisjs/repl/build/commands/AdonisRepl","commandName":"repl","description":"Start a new REPL session","args":[],"flags":[]},"db:seed":{"settings":{"loadApp":true},"commandPath":"@adonisjs/lucid/build/commands/DbSeed","commandName":"db:seed","description":"Execute database seeder files","args":[],"flags":[{"name":"connection","propertyName":"connection","type":"string","description":"Define a custom database connection for the seeders","alias":"c"},{"name":"interactive","propertyName":"interactive","type":"boolean","description":"Run seeders in interactive mode","alias":"i"},{"name":"files","propertyName":"files","type":"array","description":"Define a custom set of seeders files names to run","alias":"f"}]},"make:model":{"settings":{},"commandPath":"@adonisjs/lucid/build/commands/MakeModel","commandName":"make:model","description":"Make a new Lucid model","args":[{"type":"string","propertyName":"name","name":"name","required":true,"description":"Name of the model class"}],"flags":[{"name":"migration","propertyName":"migration","type":"boolean","alias":"m","description":"Generate the migration for the model"},{"name":"controller","propertyName":"controller","type":"boolean","alias":"c","description":"Generate the controller for the model"}]},"make:migration":{"settings":{"loadApp":true},"commandPath":"@adonisjs/lucid/build/commands/MakeMigration","commandName":"make:migration","description":"Make a new migration file","args":[{"type":"string","propertyName":"name","name":"name","required":true,"description":"Name of the migration file"}],"flags":[{"name":"connection","propertyName":"connection","type":"string","description":"Define a custom database connection for the migration"},{"name":"folder","propertyName":"folder","type":"string","description":"Pre-select a migration directory"},{"name":"create","propertyName":"create","type":"string","description":"Define the table name for creating a new table"},{"name":"table","propertyName":"table","type":"string","description":"Define the table name for altering an existing table"}]},"make:seeder":{"settings":{},"commandPath":"@adonisjs/lucid/build/commands/MakeSeeder","commandName":"make:seeder","description":"Make a new Seeder file","args":[{"type":"string","propertyName":"name","name":"name","required":true,"description":"Name of the seeder class"}],"flags":[]},"migration:run":{"settings":{"loadApp":true},"commandPath":"@adonisjs/lucid/build/commands/Migration/Run","commandName":"migration:run","description":"Run pending migrations","args":[],"flags":[{"name":"connection","propertyName":"connection","type":"string","description":"Define a custom database connection","alias":"c"},{"name":"force","propertyName":"force","type":"boolean","description":"Explicitly force to run migrations in production"},{"name":"dry-run","propertyName":"dryRun","type":"boolean","description":"Print SQL queries, instead of running the migrations"}]},"migration:rollback":{"settings":{"loadApp":true},"commandPath":"@adonisjs/lucid/build/commands/Migration/Rollback","commandName":"migration:rollback","description":"Rollback migrations to a given batch number","args":[],"flags":[{"name":"connection","propertyName":"connection","type":"string","description":"Define a custom database connection","alias":"c"},{"name":"force","propertyName":"force","type":"boolean","description":"Explictly force to run migrations in production"},{"name":"dry-run","propertyName":"dryRun","type":"boolean","description":"Print SQL queries, instead of running the migrations"},{"name":"batch","propertyName":"batch","type":"number","description":"Define custom batch number for rollback. Use 0 to rollback to initial state"}]},"migration:status":{"settings":{"loadApp":true},"commandPath":"@adonisjs/lucid/build/commands/Migration/Status","commandName":"migration:status","description":"Check migrations current status.","args":[],"flags":[{"name":"connection","propertyName":"connection","type":"string","description":"Define a custom database connection","alias":"c"}]}}
+{
+ "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
+ },
+ "commandPath": "@adonisjs/core/build/commands/ListRoutes",
+ "commandName": "list:routes",
+ "description": "List application routes",
+ "args": [],
+ "aliases": [],
+ "flags": [
+ {
+ "name": "json",
+ "propertyName": "json",
+ "type": "boolean",
+ "description": "Output as JSON"
+ }
+ ]
+ },
+ "generate:key": {
+ "settings": {},
+ "commandPath": "@adonisjs/core/build/commands/GenerateKey",
+ "commandName": "generate:key",
+ "description": "Generate a new APP_KEY secret",
+ "args": [],
+ "aliases": [],
+ "flags": []
+ },
+ "repl": {
+ "settings": {
+ "loadApp": true,
+ "environment": "repl",
+ "stayAlive": true
+ },
+ "commandPath": "@adonisjs/repl/build/commands/AdonisRepl",
+ "commandName": "repl",
+ "description": "Start a new REPL session",
+ "args": [],
+ "aliases": [],
+ "flags": []
+ },
+ "db:seed": {
+ "settings": {
+ "loadApp": true
+ },
+ "commandPath": "@adonisjs/lucid/build/commands/DbSeed",
+ "commandName": "db:seed",
+ "description": "Execute database seeder files",
+ "args": [],
+ "aliases": [],
+ "flags": [
+ {
+ "name": "connection",
+ "propertyName": "connection",
+ "type": "string",
+ "description": "Define a custom database connection for the seeders",
+ "alias": "c"
+ },
+ {
+ "name": "interactive",
+ "propertyName": "interactive",
+ "type": "boolean",
+ "description": "Run seeders in interactive mode",
+ "alias": "i"
+ },
+ {
+ "name": "files",
+ "propertyName": "files",
+ "type": "array",
+ "description": "Define a custom set of seeders files names to run",
+ "alias": "f"
+ }
+ ]
+ },
+ "make:model": {
+ "settings": {},
+ "commandPath": "@adonisjs/lucid/build/commands/MakeModel",
+ "commandName": "make:model",
+ "description": "Make a new Lucid model",
+ "args": [
+ {
+ "type": "string",
+ "propertyName": "name",
+ "name": "name",
+ "required": true,
+ "description": "Name of the model class"
+ }
+ ],
+ "aliases": [],
+ "flags": [
+ {
+ "name": "migration",
+ "propertyName": "migration",
+ "type": "boolean",
+ "alias": "m",
+ "description": "Generate the migration for the model"
+ },
+ {
+ "name": "controller",
+ "propertyName": "controller",
+ "type": "boolean",
+ "alias": "c",
+ "description": "Generate the controller for the model"
+ }
+ ]
+ },
+ "make:migration": {
+ "settings": {
+ "loadApp": true
+ },
+ "commandPath": "@adonisjs/lucid/build/commands/MakeMigration",
+ "commandName": "make:migration",
+ "description": "Make a new migration file",
+ "args": [
+ {
+ "type": "string",
+ "propertyName": "name",
+ "name": "name",
+ "required": true,
+ "description": "Name of the migration file"
+ }
+ ],
+ "aliases": [],
+ "flags": [
+ {
+ "name": "connection",
+ "propertyName": "connection",
+ "type": "string",
+ "description": "Define a custom database connection for the migration"
+ },
+ {
+ "name": "folder",
+ "propertyName": "folder",
+ "type": "string",
+ "description": "Pre-select a migration directory"
+ },
+ {
+ "name": "create",
+ "propertyName": "create",
+ "type": "string",
+ "description": "Define the table name for creating a new table"
+ },
+ {
+ "name": "table",
+ "propertyName": "table",
+ "type": "string",
+ "description": "Define the table name for altering an existing table"
+ }
+ ]
+ },
+ "make:seeder": {
+ "settings": {},
+ "commandPath": "@adonisjs/lucid/build/commands/MakeSeeder",
+ "commandName": "make:seeder",
+ "description": "Make a new Seeder file",
+ "args": [
+ {
+ "type": "string",
+ "propertyName": "name",
+ "name": "name",
+ "required": true,
+ "description": "Name of the seeder class"
+ }
+ ],
+ "aliases": [],
+ "flags": []
+ },
+ "migration:run": {
+ "settings": {
+ "loadApp": true
+ },
+ "commandPath": "@adonisjs/lucid/build/commands/Migration/Run",
+ "commandName": "migration:run",
+ "description": "Run pending migrations",
+ "args": [],
+ "aliases": [],
+ "flags": [
+ {
+ "name": "connection",
+ "propertyName": "connection",
+ "type": "string",
+ "description": "Define a custom database connection",
+ "alias": "c"
+ },
+ {
+ "name": "force",
+ "propertyName": "force",
+ "type": "boolean",
+ "description": "Explicitly force to run migrations in production"
+ },
+ {
+ "name": "dry-run",
+ "propertyName": "dryRun",
+ "type": "boolean",
+ "description": "Print SQL queries, instead of running the migrations"
+ }
+ ]
+ },
+ "migration:rollback": {
+ "settings": {
+ "loadApp": true
+ },
+ "commandPath": "@adonisjs/lucid/build/commands/Migration/Rollback",
+ "commandName": "migration:rollback",
+ "description": "Rollback migrations to a given batch number",
+ "args": [],
+ "aliases": [],
+ "flags": [
+ {
+ "name": "connection",
+ "propertyName": "connection",
+ "type": "string",
+ "description": "Define a custom database connection",
+ "alias": "c"
+ },
+ {
+ "name": "force",
+ "propertyName": "force",
+ "type": "boolean",
+ "description": "Explictly force to run migrations in production"
+ },
+ {
+ "name": "dry-run",
+ "propertyName": "dryRun",
+ "type": "boolean",
+ "description": "Print SQL queries, instead of running the migrations"
+ },
+ {
+ "name": "batch",
+ "propertyName": "batch",
+ "type": "number",
+ "description": "Define custom batch number for rollback. Use 0 to rollback to initial state"
+ }
+ ]
+ },
+ "migration:status": {
+ "settings": {
+ "loadApp": true
+ },
+ "commandPath": "@adonisjs/lucid/build/commands/Migration/Status",
+ "commandName": "migration:status",
+ "description": "Check migrations current status.",
+ "args": [],
+ "aliases": [],
+ "flags": [
+ {
+ "name": "connection",
+ "propertyName": "connection",
+ "type": "string",
+ "description": "Define a custom database connection",
+ "alias": "c"
+ }
+ ]
+ }
+ },
+ "aliases": {}
+}
diff --git a/config/app.ts b/config/app.ts
index 10397a6..ddc98a3 100644
--- a/config/app.ts
+++ b/config/app.ts
@@ -126,7 +126,7 @@ export const http: ServerConfig = {
| to set the header explicitly.
|
*/
- forceContentNegotiationToJSON: true,
+ forceContentNegotiationTo: 'application/json'
}
/*
diff --git a/config/auth.ts b/config/auth.ts
index e75732e..557179b 100644
--- a/config/auth.ts
+++ b/config/auth.ts
@@ -1,5 +1,5 @@
/**
- * Config source: https://git.io/JvyKy
+ * Config source: https://git.io/JY0mp
*
* Feel free to let us know via PR, if you find something broken in this config
* file.
@@ -17,8 +17,69 @@ import { AuthConfig } from '@ioc:Adonis/Addons/Auth'
|
*/
const authConfig: AuthConfig = {
- guard: 'api',
- list: {
+ guard: 'web',
+ guards: {
+ /*
+ |--------------------------------------------------------------------------
+ | Web Guard
+ |--------------------------------------------------------------------------
+ |
+ | Web guard uses classic old school sessions for authenticating users.
+ | If you are building a standard web application, it is recommended to
+ | use web guard with session driver
+ |
+ */
+ web: {
+ driver: 'session',
+
+ provider: {
+ /*
+ |--------------------------------------------------------------------------
+ | Driver
+ |--------------------------------------------------------------------------
+ |
+ | Name of the driver
+ |
+ */
+ driver: 'lucid',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Identifier key
+ |--------------------------------------------------------------------------
+ |
+ | The identifier key is the unique key on the model. In most cases specifying
+ | the primary key is the right choice.
+ |
+ */
+ identifierKey: 'id',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Uids
+ |--------------------------------------------------------------------------
+ |
+ | Uids are used to search a user against one of the mentioned columns. During
+ | login, the auth module will search the user mentioned value against one
+ | of the mentioned columns to find their user record.
+ |
+ */
+ uids: ['email'],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Model
+ |--------------------------------------------------------------------------
+ |
+ | The model to use for fetching or finding users. The model is imported
+ | lazily since the config files are read way earlier in the lifecycle
+ | of booting the app and the models may not be in a usable state at
+ | that time.
+ |
+ */
+ model: () => import('App/Models/User'),
+ },
+ },
/*
|--------------------------------------------------------------------------
| OAT Guard
@@ -52,6 +113,7 @@ const authConfig: AuthConfig = {
|
*/
tokenProvider: {
+ type: 'api',
driver: 'redis',
redisConnection: 'local',
foreignKey: 'user_id',
diff --git a/config/bodyparser.ts b/config/bodyparser.ts
index 0e2818a..738800c 100644
--- a/config/bodyparser.ts
+++ b/config/bodyparser.ts
@@ -53,6 +53,19 @@ const bodyParserConfig: BodyParserConfig = {
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',
],
@@ -147,6 +160,18 @@ const bodyParserConfig: BodyParserConfig = {
*/
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
diff --git a/config/database.ts b/config/database.ts
index c240aef..f4eb162 100644
--- a/config/database.ts
+++ b/config/database.ts
@@ -6,10 +6,9 @@
*/
import Env from '@ioc:Adonis/Core/Env'
-import { OrmConfig } from '@ioc:Adonis/Lucid/Orm'
-import { DatabaseConfig } from '@ioc:Adonis/Lucid/Database'
+import {DatabaseConfig} from "@ioc:Adonis/Lucid/Database";
-const databaseConfig: DatabaseConfig & { orm: Partial } = {
+const databaseConfig: DatabaseConfig = {
/*
|--------------------------------------------------------------------------
| Connection
@@ -48,21 +47,6 @@ const databaseConfig: DatabaseConfig & { orm: Partial } = {
},
},
-
- /*
- |--------------------------------------------------------------------------
- | ORM Configuration
- |--------------------------------------------------------------------------
- |
- | Following are some of the configuration options to tweak the conventional
- | settings of the ORM. For example:
- |
- | - Define a custom function to compute the default table name for a given model.
- | - Or define a custom function to compute the primary key for a given model.
- |
- */
- orm: {
- },
}
export default databaseConfig
diff --git a/contracts/auth.ts b/contracts/auth.ts
index b8f45c9..a498628 100644
--- a/contracts/auth.ts
+++ b/contracts/auth.ts
@@ -1,5 +1,5 @@
/**
- * Contract source: https://git.io/JvyKD
+ * Contract source: https://git.io/JOdz5
*
* Feel free to let us know via PR, if you find something broken in this
* file.
@@ -45,17 +45,29 @@ declare module '@ioc:Adonis/Addons/Auth' {
|--------------------------------------------------------------------------
|
| The guards are used for authenticating users using different drivers.
- | The auth module comes with 4 different guards.
+ | The auth module comes with 3 different guards.
|
| - SessionGuardContract
| - BasicAuthGuardContract
- | - JwtGuardContract
| - OATGuardContract ( Opaque access token )
|
| Every guard needs a provider for looking up users from the database.
|
*/
interface GuardsList {
+ /*
+ |--------------------------------------------------------------------------
+ | Web Guard
+ |--------------------------------------------------------------------------
+ |
+ | The web guard uses sessions for maintaining user login state. It uses
+ | the `user` provider for fetching user details.
+ |
+ */
+ web: {
+ implementation: SessionGuardContract<'user', 'web'>,
+ config: SessionGuardConfig<'user'>,
+ },
/*
|--------------------------------------------------------------------------
| OAT Guard
diff --git a/package.json b/package.json
index 62d9368..d34dbfe 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"mig": "node ace migration:run"
},
"devDependencies": {
- "@adonisjs/assembler": "^3.0.7",
+ "@adonisjs/assembler": "^5.3.0",
"adonis-preset-ts": "^2.1.0",
"pino-pretty": "^4.7.1",
"typescript": "~4.3.2",