Skip to content

Commit

Permalink
setup-error-sample
Browse files Browse the repository at this point in the history
  • Loading branch information
kidroca committed Dec 23, 2020
0 parents commit 1d0389b
Show file tree
Hide file tree
Showing 83 changed files with 12,473 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .adonisrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"typescript": true,
"commands": [
"./commands",
"@adonisjs/core/build/commands",
"@adonisjs/repl/build/commands"
],
"exceptionHandlerNamespace": "App/Exceptions/Handler",
"aliases": {
"App": "app",
"Config": "config",
"Database": "database",
"Contracts": "contracts"
},
"preloads": [
"./start/routes",
"./start/kernel"
],
"providers": [
"./providers/AppProvider",
"@adonisjs/core",
"@adonisjs/session",
"@adonisjs/view",
"@adonisjs/redis"
],
"metaFiles": [
{
"pattern": "public/**",
"reloadServer": false
},
{
"pattern": "resources/views/**/*.edge",
"reloadServer": false
}
],
"aceProviders": [
"@adonisjs/repl"
]
}
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
insert_final_newline = ignore

[*.md]
trim_trailing_whitespace = false
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PORT=
HOST=
NODE_ENV=
APP_KEY=
SESSION_DRIVER=
CACHE_VIEWS=
REDIS_CONNECTION=
REDIS_HOST=
REDIS_PORT=
REDIS_PASSWORD=
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["plugin:adonis/typescriptApp", "prettier", "prettier/@typescript-eslint"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error"]
}
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
coverage
.vscode
.DS_STORE
/.env
tmp
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"useTabs": false,
"quoteProps": "consistent",
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 100
}
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Error reproduction example

All the steps are already performed and the `build` folder committed so you can
just go inside and try

```
npm ci --production
node server.js
```

### Steps to recreate

Build the app
```
npm run build
```

Setup env variables or copy the `.env` file to `./build`

Move the `./build` folder somewhere so that it does not resolve anything from
the parent `node_modules` folder

Go inside the `build` folder

```
npm ci --production
export NODE_ENV=production
node server.js
```

Observe error

```
Error: Cannot find module 'tslib'
Require stack:
- /app/node_modules/@adonisjs/redis/build/src/RedisConnection/index.js
- /app/node_modules/@adonisjs/redis/build/src/RedisManager/index.js
- /app/node_modules/@adonisjs/redis/build/providers/RedisProvider.js
- /app/node_modules/@poppinss/utils/build/src/esmRequire.js
- /app/node_modules/@poppinss/utils/build/index.js
- /app/node_modules/@adonisjs/fold/build/src/Ioc/index.js
- /app/node_modules/@adonisjs/fold/build/index.js
- /app/node_modules/@adonisjs/application/build/index.js
- /app/node_modules/@adonisjs/core/build/standalone.js
- /app/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/app/node_modules/@adonisjs/redis/build/src/RedisConnection/index.js:12:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
```
16 changes: 16 additions & 0 deletions ace
Original file line number Diff line number Diff line change
@@ -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))
1 change: 1 addition & 0 deletions ace-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"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":[]}}
28 changes: 28 additions & 0 deletions app/Exceptions/Handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
|--------------------------------------------------------------------------
| 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 = {
'404': 'errors.not-found',
'500..599': 'errors.server-error',
}

constructor() {
super(Logger)
}
}
40 changes: 40 additions & 0 deletions build/.adonisrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"typescript": false,
"commands": [
"./commands",
"@adonisjs/core/build/commands",
"@adonisjs/repl/build/commands"
],
"exceptionHandlerNamespace": "App/Exceptions/Handler",
"aliases": {
"App": "app",
"Config": "config",
"Database": "database",
"Contracts": "contracts"
},
"preloads": [
"./start/routes",
"./start/kernel"
],
"providers": [
"./providers/AppProvider",
"@adonisjs/core",
"@adonisjs/session",
"@adonisjs/view",
"@adonisjs/redis"
],
"metaFiles": [
{
"pattern": "public/**",
"reloadServer": false
},
{
"pattern": "resources/views/**/*.edge",
"reloadServer": false
}
],
"aceProviders": [
"@adonisjs/repl"
],
"lastCompiledAt": "2020-12-23T20:54:29.424Z"
}
10 changes: 10 additions & 0 deletions build/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PORT=3333
HOST=0.0.0.0
NODE_ENV=production
APP_KEY=8xt8J2F5V007TCRAVVxKAYxas_bVdswX
SESSION_DRIVER=redis
CACHE_VIEWS=false
REDIS_CONNECTION=local
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=
16 changes: 16 additions & 0 deletions build/ace
Original file line number Diff line number Diff line change
@@ -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))
1 change: 1 addition & 0 deletions build/ace-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"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":[]}}
16 changes: 16 additions & 0 deletions build/app/Exceptions/Handler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/app/Exceptions/Handler.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions build/commands/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/commands/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions build/config/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/config/app.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions build/config/bodyparser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/config/bodyparser.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1d0389b

Please sign in to comment.