lumen-framework 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -0
- package/README.md +164 -0
- package/bin/lumen +275 -0
- package/dist/cli.cjs +3002 -0
- package/dist/cli.cjs.map +7 -0
- package/dist/index.js +6515 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +6480 -0
- package/dist/index.mjs.map +7 -0
- package/dist/types/constants.d.ts +7 -0
- package/dist/types/errors/controller-missing-error.d.ts +7 -0
- package/dist/types/errors/serializer-missing-error.d.ts +7 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/interfaces.d.ts +12 -0
- package/dist/types/packages/application/index.d.ts +97 -0
- package/dist/types/packages/application/initialize.d.ts +6 -0
- package/dist/types/packages/application/interfaces.d.ts +16 -0
- package/dist/types/packages/application/utils/create-controller.d.ts +12 -0
- package/dist/types/packages/application/utils/create-serializer.d.ts +4 -0
- package/dist/types/packages/application/utils/normalize-port.d.ts +4 -0
- package/dist/types/packages/cli/commands/build.d.ts +1 -0
- package/dist/types/packages/cli/commands/create.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbcreate.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbdrop.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbmigrate.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbrollback.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbseed.d.ts +4 -0
- package/dist/types/packages/cli/commands/destroy.d.ts +11 -0
- package/dist/types/packages/cli/commands/generate.d.ts +10 -0
- package/dist/types/packages/cli/commands/index.d.ts +12 -0
- package/dist/types/packages/cli/commands/repl.d.ts +1 -0
- package/dist/types/packages/cli/commands/serve.d.ts +8 -0
- package/dist/types/packages/cli/commands/test.d.ts +4 -0
- package/dist/types/packages/cli/constants.d.ts +2 -0
- package/dist/types/packages/cli/errors/database-config-missing.d.ts +4 -0
- package/dist/types/packages/cli/generator/constants.d.ts +5 -0
- package/dist/types/packages/cli/generator/index.d.ts +11 -0
- package/dist/types/packages/cli/generator/interfaces.d.ts +9 -0
- package/dist/types/packages/cli/generator/utils/create-generator.d.ts +9 -0
- package/dist/types/packages/cli/generator/utils/generate-type.d.ts +33 -0
- package/dist/types/packages/cli/generator/utils/generator-for.d.ts +2 -0
- package/dist/types/packages/cli/generator/utils/log.d.ts +4 -0
- package/dist/types/packages/cli/generator/utils/migration-conflict.d.ts +6 -0
- package/dist/types/packages/cli/templates/application.d.ts +5 -0
- package/dist/types/packages/cli/templates/config.d.ts +5 -0
- package/dist/types/packages/cli/templates/controller.d.ts +5 -0
- package/dist/types/packages/cli/templates/database.d.ts +5 -0
- package/dist/types/packages/cli/templates/empty-migration.d.ts +5 -0
- package/dist/types/packages/cli/templates/eslint-config.d.ts +5 -0
- package/dist/types/packages/cli/templates/gitignore.d.ts +5 -0
- package/dist/types/packages/cli/templates/license.d.ts +5 -0
- package/dist/types/packages/cli/templates/middleware.d.ts +5 -0
- package/dist/types/packages/cli/templates/model-migration.d.ts +5 -0
- package/dist/types/packages/cli/templates/model.d.ts +5 -0
- package/dist/types/packages/cli/templates/package-json.d.ts +5 -0
- package/dist/types/packages/cli/templates/readme.d.ts +5 -0
- package/dist/types/packages/cli/templates/routes.d.ts +5 -0
- package/dist/types/packages/cli/templates/seed.d.ts +5 -0
- package/dist/types/packages/cli/templates/serializer.d.ts +5 -0
- package/dist/types/packages/cli/templates/util.d.ts +5 -0
- package/dist/types/packages/cli/utils/create-prompt.d.ts +4 -0
- package/dist/types/packages/cli/utils/driver-for.d.ts +1 -0
- package/dist/types/packages/cli/utils/indent.d.ts +1 -0
- package/dist/types/packages/compiler/index.d.ts +11 -0
- package/dist/types/packages/compiler/interfaces.d.ts +1 -0
- package/dist/types/packages/compiler/utils/create-boot-script.d.ts +6 -0
- package/dist/types/packages/compiler/utils/create-manifest.d.ts +6 -0
- package/dist/types/packages/compiler/utils/format-name.d.ts +5 -0
- package/dist/types/packages/config/index.d.ts +3 -0
- package/dist/types/packages/config/interfaces.d.ts +6 -0
- package/dist/types/packages/controller/constants.d.ts +2 -0
- package/dist/types/packages/controller/index.d.ts +591 -0
- package/dist/types/packages/controller/interfaces.d.ts +13 -0
- package/dist/types/packages/controller/utils/find-many.d.ts +6 -0
- package/dist/types/packages/controller/utils/find-one.d.ts +6 -0
- package/dist/types/packages/controller/utils/params-to-query.d.ts +16 -0
- package/dist/types/packages/controller/utils/resolve-relationships.d.ts +5 -0
- package/dist/types/packages/database/attribute/index.d.ts +6 -0
- package/dist/types/packages/database/attribute/interfaces.d.ts +6 -0
- package/dist/types/packages/database/attribute/utils/create-attribute.d.ts +5 -0
- package/dist/types/packages/database/attribute/utils/create-getter.d.ts +3 -0
- package/dist/types/packages/database/attribute/utils/create-normalizer.d.ts +1 -0
- package/dist/types/packages/database/attribute/utils/create-setter.d.ts +8 -0
- package/dist/types/packages/database/change-set/index.d.ts +10 -0
- package/dist/types/packages/database/constants.d.ts +3 -0
- package/dist/types/packages/database/errors/config-missing-error.d.ts +4 -0
- package/dist/types/packages/database/errors/index.d.ts +5 -0
- package/dist/types/packages/database/errors/invalid-driver-error.d.ts +7 -0
- package/dist/types/packages/database/errors/migrations-pending-error.d.ts +7 -0
- package/dist/types/packages/database/errors/model-missing-error.d.ts +7 -0
- package/dist/types/packages/database/errors/unique-constraint-error.d.ts +4 -0
- package/dist/types/packages/database/index.d.ts +26 -0
- package/dist/types/packages/database/initialize.d.ts +6 -0
- package/dist/types/packages/database/interfaces.d.ts +85 -0
- package/dist/types/packages/database/migration/index.d.ts +12 -0
- package/dist/types/packages/database/migration/interfaces.d.ts +4 -0
- package/dist/types/packages/database/migration/utils/generate-timestamp.d.ts +2 -0
- package/dist/types/packages/database/model/index.d.ts +1046 -0
- package/dist/types/packages/database/model/initialize-class.d.ts +10 -0
- package/dist/types/packages/database/model/interfaces.d.ts +14 -0
- package/dist/types/packages/database/model/utils/get-columns.d.ts +5 -0
- package/dist/types/packages/database/model/utils/persistence.d.ts +18 -0
- package/dist/types/packages/database/model/utils/process-write-error.d.ts +4 -0
- package/dist/types/packages/database/model/utils/run-hooks.d.ts +6 -0
- package/dist/types/packages/database/model/utils/validate.d.ts +5 -0
- package/dist/types/packages/database/query/errors/index.d.ts +1 -0
- package/dist/types/packages/database/query/errors/record-not-found-error.d.ts +6 -0
- package/dist/types/packages/database/query/index.d.ts +38 -0
- package/dist/types/packages/database/query/runner/constants.d.ts +2 -0
- package/dist/types/packages/database/query/runner/index.d.ts +9 -0
- package/dist/types/packages/database/query/runner/utils/build-results.d.ts +10 -0
- package/dist/types/packages/database/query/runner/utils/get-find-param.d.ts +2 -0
- package/dist/types/packages/database/query/utils/format-select.d.ts +5 -0
- package/dist/types/packages/database/query/utils/scopes-for.d.ts +2 -0
- package/dist/types/packages/database/relationship/index.d.ts +11 -0
- package/dist/types/packages/database/relationship/interfaces.d.ts +12 -0
- package/dist/types/packages/database/relationship/utils/getters.d.ts +14 -0
- package/dist/types/packages/database/relationship/utils/inverse-setters.d.ts +15 -0
- package/dist/types/packages/database/relationship/utils/setters.d.ts +14 -0
- package/dist/types/packages/database/relationship/utils/unassociate.d.ts +5 -0
- package/dist/types/packages/database/relationship/utils/update-relationship.d.ts +5 -0
- package/dist/types/packages/database/relationship/utils/validate-type.d.ts +2 -0
- package/dist/types/packages/database/transaction/index.d.ts +16 -0
- package/dist/types/packages/database/transaction/interfaces.d.ts +5 -0
- package/dist/types/packages/database/utils/connect.d.ts +6 -0
- package/dist/types/packages/database/utils/create-migrations.d.ts +5 -0
- package/dist/types/packages/database/utils/normalize-model-name.d.ts +5 -0
- package/dist/types/packages/database/utils/pending-migrations.d.ts +4 -0
- package/dist/types/packages/database/utils/type-for-column.d.ts +5 -0
- package/dist/types/packages/database/validation/errors/index.d.ts +1 -0
- package/dist/types/packages/database/validation/errors/validation-error.d.ts +7 -0
- package/dist/types/packages/database/validation/index.d.ts +13 -0
- package/dist/types/packages/database/validation/interfaces.d.ts +5 -0
- package/dist/types/packages/freezeable/constants.d.ts +1 -0
- package/dist/types/packages/freezeable/index.d.ts +3 -0
- package/dist/types/packages/freezeable/map/index.d.ts +11 -0
- package/dist/types/packages/freezeable/set/index.d.ts +11 -0
- package/dist/types/packages/freezeable/utils/freeze.d.ts +20 -0
- package/dist/types/packages/freezeable/utils/is-frozen.d.ts +4 -0
- package/dist/types/packages/fs/index.d.ts +52 -0
- package/dist/types/packages/fs/interfaces.d.ts +19 -0
- package/dist/types/packages/fs/utils/create-path-remover.d.ts +5 -0
- package/dist/types/packages/fs/utils/create-resolver.d.ts +4 -0
- package/dist/types/packages/fs/utils/exists.d.ts +4 -0
- package/dist/types/packages/fs/utils/is-js-file.d.ts +4 -0
- package/dist/types/packages/fs/utils/parse-path.d.ts +5 -0
- package/dist/types/packages/fs/utils/rmrf.d.ts +5 -0
- package/dist/types/packages/fs/watcher/index.d.ts +13 -0
- package/dist/types/packages/fs/watcher/initialize.d.ts +5 -0
- package/dist/types/packages/fs/watcher/interfaces.d.ts +3 -0
- package/dist/types/packages/jsonapi/constants.d.ts +2 -0
- package/dist/types/packages/jsonapi/errors/index.d.ts +3 -0
- package/dist/types/packages/jsonapi/errors/invalid-content-type-error.d.ts +8 -0
- package/dist/types/packages/jsonapi/errors/not-acceptable-error.d.ts +8 -0
- package/dist/types/packages/jsonapi/errors/unsupported-media-type-error.d.ts +8 -0
- package/dist/types/packages/jsonapi/index.d.ts +5 -0
- package/dist/types/packages/jsonapi/interfaces.d.ts +66 -0
- package/dist/types/packages/jsonapi/utils/has-media-type.d.ts +4 -0
- package/dist/types/packages/jsonapi/utils/is-jsonapi.d.ts +4 -0
- package/dist/types/packages/loader/builder/index.d.ts +6 -0
- package/dist/types/packages/loader/builder/interfaces.d.ts +10 -0
- package/dist/types/packages/loader/builder/utils/create-children-builder.d.ts +2 -0
- package/dist/types/packages/loader/builder/utils/create-parent-builder.d.ts +2 -0
- package/dist/types/packages/loader/builder/utils/sort-by-namespace.d.ts +5 -0
- package/dist/types/packages/loader/index.d.ts +8 -0
- package/dist/types/packages/loader/interfaces.d.ts +4 -0
- package/dist/types/packages/loader/resolver/index.d.ts +7 -0
- package/dist/types/packages/loader/resolver/utils/closest-ancestor.d.ts +2 -0
- package/dist/types/packages/loader/resolver/utils/closest-child.d.ts +2 -0
- package/dist/types/packages/loader/utils/bundle-for.d.ts +5 -0
- package/dist/types/packages/loader/utils/format-key.d.ts +4 -0
- package/dist/types/packages/logger/constants.d.ts +8 -0
- package/dist/types/packages/logger/index.d.ts +182 -0
- package/dist/types/packages/logger/interfaces.d.ts +17 -0
- package/dist/types/packages/logger/request-logger/index.d.ts +6 -0
- package/dist/types/packages/logger/request-logger/interfaces.d.ts +25 -0
- package/dist/types/packages/logger/request-logger/templates.d.ts +9 -0
- package/dist/types/packages/logger/request-logger/utils/filter-params.d.ts +4 -0
- package/dist/types/packages/logger/request-logger/utils/log-json.d.ts +10 -0
- package/dist/types/packages/logger/request-logger/utils/log-text.d.ts +10 -0
- package/dist/types/packages/logger/utils/line.d.ts +4 -0
- package/dist/types/packages/logger/utils/sql.d.ts +4 -0
- package/dist/types/packages/logger/writer/constants.d.ts +3 -0
- package/dist/types/packages/logger/writer/index.d.ts +6 -0
- package/dist/types/packages/logger/writer/interfaces.d.ts +2 -0
- package/dist/types/packages/logger/writer/utils/format-message.d.ts +9 -0
- package/dist/types/packages/lumenify/index.d.ts +11 -0
- package/dist/types/packages/lumenify/utils/create-response-proxy.d.ts +8 -0
- package/dist/types/packages/pm/cluster/index.d.ts +21 -0
- package/dist/types/packages/pm/cluster/interfaces.d.ts +7 -0
- package/dist/types/packages/pm/index.d.ts +6 -0
- package/dist/types/packages/router/definitions/context/index.d.ts +11 -0
- package/dist/types/packages/router/definitions/context/utils/create-definition-group.d.ts +7 -0
- package/dist/types/packages/router/definitions/context/utils/create-definition.d.ts +10 -0
- package/dist/types/packages/router/definitions/context/utils/normalize-resource-args.d.ts +12 -0
- package/dist/types/packages/router/definitions/index.d.ts +10 -0
- package/dist/types/packages/router/definitions/interfaces.d.ts +7 -0
- package/dist/types/packages/router/index.d.ts +18 -0
- package/dist/types/packages/router/interfaces.d.ts +18 -0
- package/dist/types/packages/router/namespace/index.d.ts +20 -0
- package/dist/types/packages/router/namespace/interfaces.d.ts +9 -0
- package/dist/types/packages/router/namespace/utils/normalize-name.d.ts +4 -0
- package/dist/types/packages/router/namespace/utils/normalize-path.d.ts +4 -0
- package/dist/types/packages/router/resource/index.d.ts +13 -0
- package/dist/types/packages/router/resource/interfaces.d.ts +5 -0
- package/dist/types/packages/router/resource/utils/normalize-only.d.ts +5 -0
- package/dist/types/packages/router/route/action/constants.d.ts +1 -0
- package/dist/types/packages/router/route/action/enhancers/resource.d.ts +5 -0
- package/dist/types/packages/router/route/action/enhancers/track-perf.d.ts +5 -0
- package/dist/types/packages/router/route/action/index.d.ts +9 -0
- package/dist/types/packages/router/route/action/interfaces.d.ts +2 -0
- package/dist/types/packages/router/route/action/utils/create-page-links.d.ts +12 -0
- package/dist/types/packages/router/route/action/utils/get-action-name.d.ts +5 -0
- package/dist/types/packages/router/route/action/utils/get-controller-name.d.ts +5 -0
- package/dist/types/packages/router/route/constants.d.ts +1 -0
- package/dist/types/packages/router/route/index.d.ts +28 -0
- package/dist/types/packages/router/route/interfaces.d.ts +10 -0
- package/dist/types/packages/router/route/params/errors/index.d.ts +5 -0
- package/dist/types/packages/router/route/params/errors/invalid-parameter-error.d.ts +8 -0
- package/dist/types/packages/router/route/params/errors/parameter-not-nullable-error.d.ts +9 -0
- package/dist/types/packages/router/route/params/errors/parameter-required-error.d.ts +8 -0
- package/dist/types/packages/router/route/params/errors/parameter-type-error.d.ts +9 -0
- package/dist/types/packages/router/route/params/errors/parameter-value-error.d.ts +9 -0
- package/dist/types/packages/router/route/params/errors/resource-mismatch-error.d.ts +8 -0
- package/dist/types/packages/router/route/params/index.d.ts +18 -0
- package/dist/types/packages/router/route/params/interfaces.d.ts +25 -0
- package/dist/types/packages/router/route/params/parameter/index.d.ts +14 -0
- package/dist/types/packages/router/route/params/parameter/interfaces.d.ts +4 -0
- package/dist/types/packages/router/route/params/parameter/utils/validate-value.d.ts +5 -0
- package/dist/types/packages/router/route/params/parameter-group/index.d.ts +14 -0
- package/dist/types/packages/router/route/params/parameter-group/utils/has-required-params.d.ts +5 -0
- package/dist/types/packages/router/route/params/utils/get-data-params.d.ts +6 -0
- package/dist/types/packages/router/route/params/utils/get-default-collection-params.d.ts +6 -0
- package/dist/types/packages/router/route/params/utils/get-default-member-params.d.ts +5 -0
- package/dist/types/packages/router/route/params/utils/get-query-params.d.ts +14 -0
- package/dist/types/packages/router/route/params/utils/get-url-params.d.ts +5 -0
- package/dist/types/packages/router/route/params/utils/validate-resource-id.d.ts +5 -0
- package/dist/types/packages/router/route/params/utils/validate-type.d.ts +5 -0
- package/dist/types/packages/router/route/utils/get-dynamic-segments.d.ts +4 -0
- package/dist/types/packages/router/route/utils/get-static-path.d.ts +4 -0
- package/dist/types/packages/router/utils/create-replacer.d.ts +5 -0
- package/dist/types/packages/serializer/index.d.ts +521 -0
- package/dist/types/packages/serializer/interfaces.d.ts +7 -0
- package/dist/types/packages/server/constants.d.ts +2 -0
- package/dist/types/packages/server/index.d.ts +27 -0
- package/dist/types/packages/server/interfaces.d.ts +18 -0
- package/dist/types/packages/server/request/constants.d.ts +2 -0
- package/dist/types/packages/server/request/index.d.ts +8 -0
- package/dist/types/packages/server/request/interfaces.d.ts +63 -0
- package/dist/types/packages/server/request/parser/constants.d.ts +6 -0
- package/dist/types/packages/server/request/parser/errors/index.d.ts +1 -0
- package/dist/types/packages/server/request/parser/errors/malformed-request-error.d.ts +8 -0
- package/dist/types/packages/server/request/parser/index.d.ts +5 -0
- package/dist/types/packages/server/request/parser/utils/format.d.ts +17 -0
- package/dist/types/packages/server/request/parser/utils/parse-nested-object.d.ts +4 -0
- package/dist/types/packages/server/request/parser/utils/parse-read.d.ts +5 -0
- package/dist/types/packages/server/request/parser/utils/parse-write.d.ts +5 -0
- package/dist/types/packages/server/request/utils/get-domain.d.ts +5 -0
- package/dist/types/packages/server/responder/index.d.ts +5 -0
- package/dist/types/packages/server/responder/utils/data-for.d.ts +5 -0
- package/dist/types/packages/server/responder/utils/has-content-type.d.ts +2 -0
- package/dist/types/packages/server/responder/utils/normalize.d.ts +7 -0
- package/dist/types/packages/server/response/index.d.ts +5 -0
- package/dist/types/packages/server/response/interfaces.d.ts +22 -0
- package/dist/types/packages/server/utils/create-server-error.d.ts +7 -0
- package/dist/types/packages/server/utils/set-cors-headers.d.ts +3 -0
- package/dist/types/packages/server/utils/validate-accept.d.ts +4 -0
- package/dist/types/packages/server/utils/validate-content-type.d.ts +4 -0
- package/dist/types/packages/template/index.d.ts +8 -0
- package/dist/types/packages/template/utils/insert-values.d.ts +4 -0
- package/dist/types/utils/chain.d.ts +5 -0
- package/dist/types/utils/compact.d.ts +11 -0
- package/dist/types/utils/compose.d.ts +19 -0
- package/dist/types/utils/create-query-string.d.ts +6 -0
- package/dist/types/utils/diff.d.ts +4 -0
- package/dist/types/utils/entries.d.ts +4 -0
- package/dist/types/utils/env.d.ts +3 -0
- package/dist/types/utils/exec.d.ts +5 -0
- package/dist/types/utils/github.d.ts +9 -0
- package/dist/types/utils/has-own-property.d.ts +1 -0
- package/dist/types/utils/insert.d.ts +4 -0
- package/dist/types/utils/is-buffer.d.ts +4 -0
- package/dist/types/utils/is-null.d.ts +4 -0
- package/dist/types/utils/is-object.d.ts +17 -0
- package/dist/types/utils/is-undefined.d.ts +4 -0
- package/dist/types/utils/k.d.ts +10 -0
- package/dist/types/utils/map-to-object.d.ts +1 -0
- package/dist/types/utils/merge.d.ts +4 -0
- package/dist/types/utils/omit.d.ts +9 -0
- package/dist/types/utils/pick.d.ts +11 -0
- package/dist/types/utils/present.d.ts +4 -0
- package/dist/types/utils/promise-hash.d.ts +9 -0
- package/dist/types/utils/proxy.d.ts +6 -0
- package/dist/types/utils/range.d.ts +4 -0
- package/dist/types/utils/set-type.d.ts +11 -0
- package/dist/types/utils/sleep.d.ts +4 -0
- package/dist/types/utils/stringify.d.ts +4 -0
- package/dist/types/utils/transform-keys.d.ts +29 -0
- package/dist/types/utils/try-catch.d.ts +55 -0
- package/dist/types/utils/underscore.d.ts +4 -0
- package/dist/types/utils/uniq.d.ts +4 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Postlight
|
|
4
|
+
Copyright (c) 2019-2026 Nick Schot and contributors
|
|
5
|
+
|
|
6
|
+
Lumen is a fork of Lux (https://github.com/postlight/lux). The copyright notice
|
|
7
|
+
above is retained for the original work, as the MIT License requires; the second
|
|
8
|
+
line covers the changes made in this fork.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Lumen
|
|
2
|
+
|
|
3
|
+
[](https://github.com/nickschot/lux/actions/workflows/ci.yml) [
|
|
4
|
+
|
|
5
|
+
A MVC style framework for building highly performant, large scale JSON APIs that anybody who knows the JavaScript language and its modern features will understand.
|
|
6
|
+
|
|
7
|
+
\* _Inspired by [Rails](https://github.com/rails/rails/), [Ember](http://emberjs.com/), and [React](https://facebook.github.io/react/)._
|
|
8
|
+
|
|
9
|
+
**Disclaimer:**
|
|
10
|
+
|
|
11
|
+
This isn't another wrapper around [Express](http://expressjs.com/) or a framework for building frameworks. This also isn't a replacement for server-side frameworks that render DHTML.
|
|
12
|
+
|
|
13
|
+
[Check out the Medium Article!](https://trackchanges.postlight.com/not-another-node-js-framework-33103ebeedf8)
|
|
14
|
+
|
|
15
|
+
## What?
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* Automatic CRUD actions in controllers
|
|
20
|
+
* Automatic pagination, sorting, filtering via query params in controllers
|
|
21
|
+
* CLI for eliminating boiler plate
|
|
22
|
+
* [JSON API](http://jsonapi.org/) 1.0 compliant out of the box
|
|
23
|
+
* Optimized database queries based on serialized attributes and associations
|
|
24
|
+
* Highly extensible - just write reusable JavaScript functions
|
|
25
|
+
* Pairs nicely with client-side JavaScript applications 🍷
|
|
26
|
+
* Easy to contribute
|
|
27
|
+
* Routes are stored and accessed via a `Map` not an `Array`
|
|
28
|
+
* Embraces ES2015 and beyond
|
|
29
|
+
* Classes
|
|
30
|
+
* Modules
|
|
31
|
+
* Promises & async/await
|
|
32
|
+
* Arrow Functions
|
|
33
|
+
* etc.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Philosophies
|
|
37
|
+
|
|
38
|
+
##### Minimal API surface area
|
|
39
|
+
|
|
40
|
+
Lumen uses JavaScript's standard library rather than creating a ton of functions you'll have to learn and remember.
|
|
41
|
+
|
|
42
|
+
After your learn how to use it, you'll rarely need to look at the docs.
|
|
43
|
+
|
|
44
|
+
##### Pure functions are awesome
|
|
45
|
+
|
|
46
|
+
Or more appropriately somewhat pure functions are awesome.
|
|
47
|
+
|
|
48
|
+
Serving content is done by returning objects, arrays, or other primitives rather than calling `res.end(/* content */);` and returning nothing.
|
|
49
|
+
|
|
50
|
+
##### Convention over configuration
|
|
51
|
+
|
|
52
|
+
[Rails](http://rubyonrails.org/) and [Ember](http://emberjs.com/) are great because they make hard decisions for you and make it possible to submit a PR on your first day at a new company. This is rare with Node server frameworks.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Why?
|
|
56
|
+
|
|
57
|
+
Frameworks like Rails are pretty great. You can build amazing applications in a reasonable amount of time without a ton of developers working on a project. They have their limitations though. They can be slow and sometimes hard to scale. Not to mention WebSocket support being so-so.
|
|
58
|
+
|
|
59
|
+
##### Node to the rescue.
|
|
60
|
+
|
|
61
|
+
It's fast, it allows the developer to get low level with a relatively simple API, WebSockets are stable and supported out of the box, and last but not least it's just JavaScript.
|
|
62
|
+
|
|
63
|
+
##### Not so fast (metaphorically speaking).
|
|
64
|
+
|
|
65
|
+
The last bit there "It's just JavaScript" has actually been somewhat of a double-edged sword. This has positioned Node as a "great prototyping tool" or "only used for micro services."
|
|
66
|
+
|
|
67
|
+
I can somewhat see why people would think that when returning a list of the first 10 records from a SQL database table looks like this:
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
app.get('/posts', (req, res) => {
|
|
71
|
+
Post.findAll()
|
|
72
|
+
.then(posts => {
|
|
73
|
+
res.status(200).json(posts);
|
|
74
|
+
}, err => {
|
|
75
|
+
console.error(err);
|
|
76
|
+
res.status(500).send(err.message);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Could you imagine how ugly that gets when you have to implement pagination, filtering, sorting, or—better yet—formatting the response for JSON API?
|
|
82
|
+
|
|
83
|
+
Also, where does that code live? In what file and folder would I find it? What pattern do you use for organizing this code?
|
|
84
|
+
|
|
85
|
+
😲 Ok ok give me back Rails I'll worry about performance and scaling later. After all, premature optimization is the root of all evil.
|
|
86
|
+
|
|
87
|
+
##### Problem.resolve();
|
|
88
|
+
|
|
89
|
+
Shouldn't there be a better way to do this? Can't I just return a promise or a JavaScript primitive instead of basically using the native Node http server API?
|
|
90
|
+
|
|
91
|
+
Fortunately ES2015+ has introduced great new features to the JavaScript language, especially when it comes to meta programming.
|
|
92
|
+
|
|
93
|
+
With Lumen your code from before can now look like this:
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
class PostsController extends Controller {
|
|
97
|
+
index(req, res) {
|
|
98
|
+
return Post.all();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Except CRUD actions are taken care of automatically so it would actually look like this:
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
class PostsController extends Controller {
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
It's about time a Node server framework learned something from client-side JS frameworks.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## How?
|
|
115
|
+
|
|
116
|
+
### Installation
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install -g lumen-framework
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Creating Your First Project
|
|
123
|
+
|
|
124
|
+
Use the `new` command to create your first project.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
lumen new <app-name>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Running
|
|
131
|
+
|
|
132
|
+
To run your application use the `serve` command.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
cd <app-name>
|
|
136
|
+
lumen serve
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Useful Links
|
|
140
|
+
|
|
141
|
+
* [JSON API](http://jsonapi.org/)
|
|
142
|
+
* [Knex.js](http://knexjs.org/)
|
|
143
|
+
* [Vitest](https://vitest.dev/)
|
|
144
|
+
|
|
145
|
+
## Attribution
|
|
146
|
+
|
|
147
|
+
Lumen is a fork of [**Lux**](https://github.com/postlight/lux), created by
|
|
148
|
+
[Zachary Golba](https://github.com/zacharygolba) and originally developed and maintained by
|
|
149
|
+
[Postlight](https://postlight.com/). Essentially all of the framework's design — the
|
|
150
|
+
convention-over-configuration approach, the automatic CRUD controllers, the JSON:API
|
|
151
|
+
serialization, the ORM built on Knex — is their work.
|
|
152
|
+
|
|
153
|
+
Upstream development stopped after `v1.2.3` (2018). This fork picks it up from there: it
|
|
154
|
+
was renamed to Lumen to avoid confusion with the original, since it is no longer a
|
|
155
|
+
drop-in continuation of it — the toolchain has been modernized (TypeScript, esbuild,
|
|
156
|
+
Vitest, Node 20+) and the public API has been allowed to change. Lumen is **not** an
|
|
157
|
+
official Postlight project, and the Postlight team provides no support for it.
|
|
158
|
+
|
|
159
|
+
The original is MIT licensed, and Lumen remains MIT licensed under the same terms. The
|
|
160
|
+
original copyright notice is retained in [LICENSE](./LICENSE) alongside that of this
|
|
161
|
+
fork's contributors.
|
|
162
|
+
|
|
163
|
+
* Original repository: [postlight/lux](https://github.com/postlight/lux)
|
|
164
|
+
* Original announcement: [Not Another Node.js Framework](https://trackchanges.postlight.com/not-another-node-js-framework-33103ebeedf8)
|
package/bin/lumen
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --enable-source-maps
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// `--enable-source-maps` (above) replaces the `source-map-support` shim the app
|
|
6
|
+
// compiler used to inject into every bundle: the flag applies process-wide, so
|
|
7
|
+
// the required app bundle and the cluster workers (which inherit execArgv) both
|
|
8
|
+
// map stack traces back to source.
|
|
9
|
+
|
|
10
|
+
const { EOL } = require('os');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { existsSync } = require('fs');
|
|
13
|
+
|
|
14
|
+
const cli = require('commander');
|
|
15
|
+
const { red, green } = require('chalk');
|
|
16
|
+
|
|
17
|
+
const { version: VERSION } = require('../package.json');
|
|
18
|
+
|
|
19
|
+
function inLumenProject() {
|
|
20
|
+
const cwd = process.cwd();
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const { dependencies } = require(path.join(cwd, 'package.json'));
|
|
24
|
+
|
|
25
|
+
if (dependencies && dependencies['lumen-framework']) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
} catch (err) {
|
|
29
|
+
// No readable package.json here — fall through to the layout check below.
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Fall back to detecting the application layout the compiler requires.
|
|
33
|
+
//
|
|
34
|
+
// This used to match a hardcoded `lumen/test/test-app` path fragment, which
|
|
35
|
+
// existed because the framework's own fixture app does not depend on the
|
|
36
|
+
// framework. That broke the moment the project was renamed (the checkout is
|
|
37
|
+
// still `lux/`), taking the whole suite with it — and it would break again
|
|
38
|
+
// for anyone whose directory happens to be named differently. Checking for
|
|
39
|
+
// the app's shape is both rename-proof and closer to the real question.
|
|
40
|
+
return (
|
|
41
|
+
existsSync(path.join(cwd, 'app', 'index.js'))
|
|
42
|
+
&& existsSync(path.join(cwd, 'config', 'database.js'))
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function commandNotFound(cmd) {
|
|
47
|
+
console.log(
|
|
48
|
+
`${EOL} ${red(cmd)} is not a valid command.${EOL.repeat(2)}`,
|
|
49
|
+
` Use ${green('lumen --help')} for a full list of commands.${EOL}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function setEnvVar(key, val, def) {
|
|
54
|
+
if (val) {
|
|
55
|
+
Reflect.set(process.env, key, val);
|
|
56
|
+
} else if (!Reflect.has(process.env, key)) {
|
|
57
|
+
Reflect.set(process.env, key, def);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function exec(cmd, ...args) {
|
|
62
|
+
const handler = require('../dist/cli.cjs')[cmd];
|
|
63
|
+
const needsProject = new RegExp(
|
|
64
|
+
'^(?:db:.+|test|build|serve|console|generate|destroy)$'
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
if (needsProject.test(cmd) && !inLumenProject()) {
|
|
68
|
+
return Promise.reject(
|
|
69
|
+
new Error('Directory does not contain a valid Lumen application.')
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return handler(...args);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function exit(code) {
|
|
77
|
+
process.exit(typeof code === 'number' ? code : 0);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function rescue(err) {
|
|
81
|
+
console.error(err.stack);
|
|
82
|
+
exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
cli.version(VERSION);
|
|
86
|
+
|
|
87
|
+
cli
|
|
88
|
+
.command('n <name>')
|
|
89
|
+
.alias('new')
|
|
90
|
+
.description('Create a new application')
|
|
91
|
+
.option(
|
|
92
|
+
'--database [database]',
|
|
93
|
+
'Database driver',
|
|
94
|
+
/^(postgres|sqlite|mysql)$/i,
|
|
95
|
+
'sqlite'
|
|
96
|
+
)
|
|
97
|
+
.action((name, { database }) => {
|
|
98
|
+
exec('create', name, database).then(exit).catch(rescue);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
cli
|
|
102
|
+
.command('t')
|
|
103
|
+
.alias('test')
|
|
104
|
+
.description("Run your application's test suite")
|
|
105
|
+
.action(() => {
|
|
106
|
+
exec('test').then(exit).catch(rescue);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
cli
|
|
110
|
+
.command('b')
|
|
111
|
+
.alias('build')
|
|
112
|
+
.description('Build your application')
|
|
113
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
114
|
+
.action(({ useWeak }) => {
|
|
115
|
+
exec('build', !useWeak).then(exit).catch(rescue);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
cli
|
|
119
|
+
.command('c')
|
|
120
|
+
.alias('console')
|
|
121
|
+
.description('Load your application into a repl')
|
|
122
|
+
.option('-e, --environment [env]', '(Default: development)')
|
|
123
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
124
|
+
.action(({ environment, useWeak }) => {
|
|
125
|
+
setEnvVar('NODE_ENV', environment, 'development');
|
|
126
|
+
process.env.LUMEN_CONSOLE = true;
|
|
127
|
+
|
|
128
|
+
exec('build', !useWeak)
|
|
129
|
+
.then(() => exec('repl'))
|
|
130
|
+
.then(exit)
|
|
131
|
+
.catch(rescue);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
cli
|
|
135
|
+
.command('s')
|
|
136
|
+
.alias('serve')
|
|
137
|
+
.description('Serve your application')
|
|
138
|
+
.option('-c, --cluster', 'Run in cluster mode')
|
|
139
|
+
.option('-e, --environment [env]', '(Default: development)')
|
|
140
|
+
.option('-p, --port [port]', '(Default: 4000)', port =>
|
|
141
|
+
Number.parseInt(port, 10)
|
|
142
|
+
)
|
|
143
|
+
.option('-H, --hot', 'Reload when a file change is detected')
|
|
144
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
145
|
+
.action(({ hot, port, cluster, environment, useWeak }) => {
|
|
146
|
+
const useStrict = !useWeak;
|
|
147
|
+
|
|
148
|
+
setEnvVar('PORT', port, 4000);
|
|
149
|
+
setEnvVar('NODE_ENV', environment, 'development');
|
|
150
|
+
|
|
151
|
+
exec('build', useStrict)
|
|
152
|
+
.then(() => exec('serve', { hot, cluster, useStrict }))
|
|
153
|
+
.catch(rescue);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
cli
|
|
157
|
+
.command('g <type> <name> [attrs...]')
|
|
158
|
+
.alias('generate')
|
|
159
|
+
.description(
|
|
160
|
+
'Example: lumen generate model user name:string email:string admin:boolean'
|
|
161
|
+
)
|
|
162
|
+
.action((type, name, attrs) => {
|
|
163
|
+
exec('generate', { type, name, attrs }).then(exit).catch(rescue);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
cli
|
|
167
|
+
.command('d')
|
|
168
|
+
.alias('destroy <type> <name>')
|
|
169
|
+
.description('Example: lumen destroy model user')
|
|
170
|
+
.action((type, name) => {
|
|
171
|
+
exec('destroy', { type, name }).then(exit).catch(rescue);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
cli
|
|
175
|
+
.command('db:create')
|
|
176
|
+
.description('Create your database schema')
|
|
177
|
+
.option('-e, --environment [env]', '(Default: development)')
|
|
178
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
179
|
+
.action(({ environment, useWeak }) => {
|
|
180
|
+
const useStrict = !useWeak;
|
|
181
|
+
|
|
182
|
+
setEnvVar('NODE_ENV', environment, 'development');
|
|
183
|
+
|
|
184
|
+
exec('build', useStrict)
|
|
185
|
+
.then(() => exec('dbcreate'))
|
|
186
|
+
.then(exit)
|
|
187
|
+
.catch(rescue);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
cli
|
|
191
|
+
.command('db:drop')
|
|
192
|
+
.description('Drop your database schema')
|
|
193
|
+
.option('-e, --environment [env]', '(Default: development)')
|
|
194
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
195
|
+
.action(({ environment, useWeak }) => {
|
|
196
|
+
const useStrict = !useWeak;
|
|
197
|
+
|
|
198
|
+
setEnvVar('NODE_ENV', environment, 'development');
|
|
199
|
+
|
|
200
|
+
exec('build', useStrict)
|
|
201
|
+
.then(() => exec('dbdrop'))
|
|
202
|
+
.then(exit)
|
|
203
|
+
.catch(rescue);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
cli
|
|
207
|
+
.command('db:reset')
|
|
208
|
+
.description('Drop your database schema and create a new schema')
|
|
209
|
+
.option('-e, --environment [env]', '(Default: development)')
|
|
210
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
211
|
+
.action(({ environment, useWeak }) => {
|
|
212
|
+
const useStrict = !useWeak;
|
|
213
|
+
|
|
214
|
+
setEnvVar('NODE_ENV', environment, 'development');
|
|
215
|
+
|
|
216
|
+
exec('build', useStrict)
|
|
217
|
+
.then(() => exec('dbdrop'))
|
|
218
|
+
.then(() => exec('dbcreate'))
|
|
219
|
+
.then(exit)
|
|
220
|
+
.catch(rescue);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
cli
|
|
224
|
+
.command('db:migrate')
|
|
225
|
+
.description('Run database migrations')
|
|
226
|
+
.option('-e, --environment [env]', '(Default: development)')
|
|
227
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
228
|
+
.action(({ environment, useWeak }) => {
|
|
229
|
+
const useStrict = !useWeak;
|
|
230
|
+
|
|
231
|
+
setEnvVar('NODE_ENV', environment, 'development');
|
|
232
|
+
|
|
233
|
+
exec('build', useStrict)
|
|
234
|
+
.then(() => exec('dbmigrate'))
|
|
235
|
+
.then(exit)
|
|
236
|
+
.catch(rescue);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
cli
|
|
240
|
+
.command('db:rollback')
|
|
241
|
+
.description('Rollback the last database migration')
|
|
242
|
+
.option('-e, --environment [env]', '(Default: development)')
|
|
243
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
244
|
+
.action(({ environment, useWeak }) => {
|
|
245
|
+
const useStrict = !useWeak;
|
|
246
|
+
|
|
247
|
+
setEnvVar('NODE_ENV', environment, 'development');
|
|
248
|
+
|
|
249
|
+
exec('build', useStrict)
|
|
250
|
+
.then(() => exec('dbrollback'))
|
|
251
|
+
.then(exit)
|
|
252
|
+
.catch(rescue);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
cli
|
|
256
|
+
.command('db:seed')
|
|
257
|
+
.description('Add fixtures to your db from the seed function')
|
|
258
|
+
.option('-e, --environment [env]', '(Default: development)')
|
|
259
|
+
.option('-w, --use-weak', 'Use weak mode')
|
|
260
|
+
.action(({ environment, useWeak }) => {
|
|
261
|
+
const useStrict = !useWeak;
|
|
262
|
+
|
|
263
|
+
setEnvVar('NODE_ENV', environment, 'development');
|
|
264
|
+
|
|
265
|
+
exec('build', useStrict)
|
|
266
|
+
.then(() => exec('dbseed'))
|
|
267
|
+
.then(exit)
|
|
268
|
+
.catch(rescue);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
cli.on('*', commandNotFound).parse(process.argv);
|
|
272
|
+
|
|
273
|
+
if (!cli.args.length) {
|
|
274
|
+
cli.help();
|
|
275
|
+
}
|