34 Commits

Author SHA1 Message Date
Nitwel
3219bfe38f Fix status on shutdown (#18010)
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: Brainslug <tim@brainslug.nl>
2023-04-05 14:50:15 +00:00
Rijk van Zanten
2983e61870 The Great TypeScript Modernization Program Season 3 Episode 6: The Big One (#18014)
* Step 1

* Step 2

* False sense of confidence

* Couple more before dinner

* Update schema package

* Update format-title

* Upgrade specs file

* Close

* Replace ts-node-dev with tsx, and various others

* Replace lodash with lodash-es

* Add lodash-es types

* Update knex import

* More fun is had

* FSE

* Consolidate repos

* Various tweaks and fixes

* Fix specs

* Remove dependency on knex-schema-inspector

* Fix wrong imports of inspector

* Move shared exceptions to new package

* Move constants to separate module

* Move types to new types package

* Use directus/types

* I believe this is no longer needed

* [WIP] Start moving utils to esm

* ESMify Shared

* Move shared utils to  @directus/utils

* Use @directus/utils instead of @directus/shared/utils

* It runs!

* Use correct schemaoverview type

* Fix imports

* Fix the thing

* Start on new update-checker lib

* Use new update-check package

* Swap out directus/shared in app

* Pushing through the last bits now

* Dangerously make extensions SDK ESM

* Use @directus/types in tests

* Copy util function to test

* Fix linter config

* Add missing import

* Hot takes

* Fix build

* Curse these default exports

* No tests in constants

* Add tests

* Remove tests from types

* Add tests for exceptions

* Fix test

* Fix app tests

* Fix import in test

* Fix various tests

* Fix specs export

* Some more tests

* Remove broken integration tests

These were broken beyond repair.. They were also written before we really knew what we we're doing with tests, so I think it's better to say goodbye and start over with these

* Regenerate lockfile

* Fix imports from merge

* I create my own problems

* Make sharp play nice

* Add vitest config

* Install missing blackbox dep

* Consts shouldn't be in types

tsk tsk tsk tsk

* Fix type/const usage in extensions-sdk

* cursed.default

* Reduce circular deps

* Fix circular dep in items service

* vvv

* Trigger testing for all vendors

* Add workaround for rollup

* Prepend the file protocol for the ESM loader to be compatible with Windows
"WARN: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'"

* Fix postgres

* Schema package updates

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>

* Resolve cjs/mjs extensions

* Clean-up eslint config

* fixed extension concatination

* using string interpolation for consistency

* Revert MySQL optimisation

* Revert testing for all vendors

* Replace tsx with esbuild-kit/esm-loader

Is a bit faster and we can rely on the built-in `watch` and `inspect`
functionalities of Node.js

Note: The possibility to watch other files (.env in our case) might be
added in the future, see https://github.com/nodejs/node/issues/45467

* Use exact version for esbuild-kit/esm-loader

* Fix import

---------

Co-authored-by: ian <licitdev@gmail.com>
Co-authored-by: Brainslug <tim@brainslug.nl>
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
2023-04-04 17:41:56 -04:00
Rijk van Zanten
80f4807a09 TS Config Modernization Program Part 3 of many (#17904)
* noImplicitOverride: true

* noImplicitReturns: true

* noPropertyAccessFromIndexSignature: true
2023-03-23 16:47:55 -04:00
Rijk van Zanten
1a5f06c791 TSConfig Modernization: Set importsNotUsedAsValues (#17887)
* Set importsNotUsedAsValues

* Fix import
2023-03-22 14:51:27 -04:00
Michael Lopez
c561826572 Support listen parameter (#11465)
* Support listen option for allowing server to listen on wanted IP address or host

* Change default listen value from localhost to 0.0.0.0

* Update LISTEN variable to HOST

* fix formatting

* Update docs/configuration/config-options.md

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2022-02-28 21:09:27 +00:00
José Varela
d4be6e0437 Add support to extend server properties (#11869) 2022-02-26 12:11:24 -05:00
gkielwasser
053d2a6a37 Expose server instance in action hook 'server.start' (#9616)
* Expose server instance in action hook 'server.start'

* Expose server in start/stop

* Update documentation
2021-11-09 16:28:24 +00:00
Nicola Krumschmidt
3d0e086c55 Rework hook registration (#8027)
* Rework hook registration

* Remove event and action fields from hook payloads

* Move "error" action to "request.error" filter

* Emit meta and context objects in filters and actions

* Run filters sequentially

* Update hook templates

* Fix CLI hook test

* Also emit `<collection>.items.crud` when emitting `items.crud`.

* Update hook docs

Co-authored-by: Oreilles <oreilles.github@nitoref.io>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-11-03 17:18:56 -04:00
rijkvanzanten
9b210ed597 Move startServer to server.ts 2021-09-13 17:48:36 -04:00
Nicola Krumschmidt
7d8aa9fced Replace DIRECTUS_DEV env var with NODE_ENV and SERVE_APP (#6929) 2021-07-22 23:47:56 +02:00
Rijk van Zanten
77e00b7db4 Don't initialize database on file require (#6003) 2021-06-02 11:41:42 -04:00
rijkvanzanten
801e868554 Fix remaining eslint errors
h/t @paescuj
2021-04-29 15:55:12 -04:00
Pascal Jufer
acd41eb0be Syntax fixes (#5367)
* Declare return types on functions

And a very few other type related minor fixes

* Minor syntax fixes

* Remove unnecessary escape chars in regexes
* Remove unnecessary awaits
* Replace deprecated req.connection with req.socket
* Replace deprecated upload with uploadOne
* Remove unnecessary eslint-disable-next-line comments
* Comment empty functions / catch or finally clauses
* Fix irregular whitespaces
* Add missing returns (null)
* Remove unreachable code
* A few logical fixes
* Remove / Handle non-null assertions which are certainly unnecessary (e.g. in
tests)
2021-04-29 12:11:43 -04:00
rijkvanzanten
b629bf61d0 Rely on url.parse for path extraction
Doesn't break on illegal URLs
2021-04-21 09:41:53 -04:00
WoLfulus
b8e7c80b72 Application initialization events (#3680)
* Adds `not_found` hook

* Separate hooks and endpoints initialization process

* Adds additional application events

* Remove unused import

* Change the event order to accound for notFound and errorHandler

* Change emitAsync.catch to use the emitAsyncSafe function

* Updated docs, reordered table by lifecycle and usage
2021-02-08 12:30:09 -05:00
WoLfulus
7f3e095a1f Enable base and admin routes when developing a Directus app 2020-12-17 11:42:50 -03:00
Igor Savin
7cddb458cb Run prettier across app and api 2020-12-08 02:22:00 +02:00
rijkvanzanten
83971d9bc6 Make app / server creation async
Fixes #690
2020-10-19 16:38:15 -04:00
rijkvanzanten
a0d909f7d9 Cleanup server file a bit 2020-10-19 16:21:38 -04:00
WoLfulus
4662ede22f Adds separate path and host 2020-10-17 13:43:21 -03:00
WoLfulus
13285ff522 Added response events to the server 2020-10-17 13:26:24 -03:00
rijkvanzanten
0b894138b7 Move start to separate file 2020-10-15 12:44:21 -04:00
rijkvanzanten
0e0d5e8213 Start server when running file directly with Node 2020-10-15 12:34:57 -04:00
rijkvanzanten
a39b762c81 Move start functionality to server.ts 2020-10-15 12:31:57 -04:00
rijkvanzanten
a4092a070d Add server.start / server.start.before / server.stop / server.stop.before 2020-10-15 12:19:14 -04:00
rijkvanzanten
cc950b5510 Move main server logic out of cli 2020-10-15 12:15:37 -04:00
rijkvanzanten
23458b5b9f Last port change, promise 2020-10-02 16:26:40 -04:00
rijkvanzanten
1524c3e398 Change default port to 8805 2020-10-02 14:56:39 -04:00
rijkvanzanten
a67b338f09 Don't validate env in server 2020-09-08 14:57:21 -04:00
rijkvanzanten
bc4b493ff9 Do checks before starting server 2020-08-04 13:21:51 -04:00
rijkvanzanten
2252d5a35f Use centralized env export with validator function 2020-08-04 13:10:49 -04:00
rijkvanzanten
a0306b1b8a Force api to dev port on development mode 2020-08-03 18:10:37 -04:00
rijkvanzanten
a99a7f47f4 Use port 41201 instead of 3000 by default 2020-08-03 17:44:09 -04:00
rijkvanzanten
bde7069cce Move api into api subdirectory 2020-07-29 11:22:56 -04:00