未验证 提交 39981945 编写于 作者: J Jim LAURIE 提交者: GitHub

Merge branch 'master' into feature/2432

......@@ -32,6 +32,8 @@ If you send a pull request, please do it against the `master` branch. We are dev
## Setup Development Environment
To facilitate the contribution, we drastically reduce the amount of commands necessary to install the entire development environment. First of all, you need to check if you're using the [required versions of Node.js and npm](https://strapi.io/documentation/3.x.x/getting-started/installation.html#requirements)
**Note: Fish shell users** - due to the way fish shell deals with symlinks, the following steps will not work.
Then, please follow the instructions below:
#### 1. ▪️ Fork the repository
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
......@@ -60,7 +60,7 @@ Node:
**Please note that right now Node 11 is not Officially supported, and the current Node LTS (v10) should be used.**
Database:
* MongoDB >= 3.x
* MongoDB >= 3.x
* MySQL >= 5.6
* MariaDB >= 10.1
* PostgreSQL >= 10
......@@ -71,7 +71,7 @@ Database:
npm install strapi@alpha -g
````
**We recommend to use the latest version of Strapi to start your new project**.
**We recommend to use the latest version of Strapi to start your new project**.
Some breaking changes might happen, new releases are shipped every two weeks to fix/enhance the product.
#### 🏗 Create a new project
......@@ -140,7 +140,7 @@ For general help using Strapi, please refer to [the official Strapi documentatio
#### Professional support
[Strapi Solutions](https://strapi.io), the company behind Strapi, provides a full range of solutions to get better results, faster. We're always looking for the next challenge: coaching, consulting, training, customization, etc.
[Strapi Solutions](https://strapi.io), the company behind Strapi, provides a full range of solutions to get better results, faster. We're always looking for the next challenge: coaching, consulting, training, customization, etc.
[Drop us an email](mailto:support@strapi.io) to see how we can help you.
......@@ -160,4 +160,4 @@ Check out our [roadmap](https://portal.productboard.com/strapi) to get informed
## License
[MIT License](LICENSE.md) Copyright (c) 2015-2018 [Strapi Solutions](https://strapi.io/).
[MIT License](LICENSE.md) Copyright (c) 2015-2019 [Strapi Solutions](https://strapi.io/).
......@@ -7,11 +7,8 @@ Enable the middleware in environments settings
**Path —** `config/environments/middleware.json`.
```json
{
"ejs": {
"enabled": true,
"viewExt": "ejs",
"debug": false,
"cache": false
"responseTime": {
"enabled": true
},
}
```
......
......@@ -10,7 +10,7 @@ Create a new project
```bash
strapi new <name>
options: [--dev|--dbclient=<dbclient> --dbhost=<dbhost> --dbport=<dbport> --dbname=<dbname> --dbusername=<dbusername> --dbpassword=<dbpassword> --dbssl=<dbssl> --dbauth=<dbauth> --dbforce]
options: [--dev|--debug|--dbclient=<dbclient> --dbhost=<dbhost> --dbport=<dbport> --dbname=<dbname> --dbusername=<dbusername> --dbpassword=<dbpassword> --dbssl=<dbssl> --dbauth=<dbauth> --dbforce]
```
- **strapi new &#60;name&#62;**<br/>
......@@ -18,8 +18,12 @@ options: [--dev|--dbclient=<dbclient> --dbhost=<dbhost> --dbport=<dbport> --dbna
- **strapi new &#60;name&#62; --dev**<br/>
Generates a new project called **&#60;name&#62;** and creates symlinks for the `./admin` folder and each plugin inside the `./plugin` folder. It means that the Strapi's development workflow has been set up on the machine earlier.
- **strapi new &#60;name&#62; --debug**<br/>
Will display the full error message if one is fired during the database connection.
- **strapi new &#60;name&#62; --dbclient=&#60;dbclient&#62; --dbhost=&#60;dbhost&#62; --dbport=&#60;dbport&#62; --dbname=&#60;dbname&#62; --dbusername=&#60;dbusername&#62; --dbpassword=&#60;dbpassword&#62; --dbssl=&#60;dbssl&#62; --dbauth=&#60;dbauth&#62; --dbforce**<br/>
Generates a new project called **&#60;name&#62;** and skip the interactive database configuration and initilize with these options.
- **&#60;dbclient&#62;** can be `mongo`, `postgres`, `mysql`.
- **&#60;dbssl&#62;** and **&#60;dbauth&#62;** are available only for `mongo` and are optional.
......
......@@ -106,7 +106,7 @@ Please refer to the [filters' guide](../guides/filters.md) for more informations
## Models
Models are a representation of the database's structure and lifecyle. They are split into two separate files. A JavaScript file that contains the lifecycle callbacks, and a JSON one that represents the data stored in the database and their format. The models also allow you to define the relationships between them.
Models are a representation of the database's structure and lifecycle. They are split into two separate files. A JavaScript file that contains the lifecycle callbacks, and a JSON one that represents the data stored in the database and their format. The models also allow you to define the relationships between them.
**Path —** `./api/user/models/User.js`.
```js
......
......@@ -39,6 +39,10 @@ The CLI will ask you to choose your database: select MongoDB, Postgres or MySQL.
This action creates a new folder named `my-project` with the entire [files structure](../concepts/concepts.md#files-structure) of a Strapi application.
::: note
Unfortunately, there is an issue on Windows, you will probably be stuck and unable to enter your `Database name` to continue. Using a VM is one of the solutions. See [the issue](https://github.com/strapi/strapi/issues/1281).
:::
**#3 — Go to your project and launch the server:**
In your terminal run the following commands:
......
......@@ -85,7 +85,7 @@ Requests system can be implemented in custom code sections.
To extract the filters from an JavaScript object or a request, you need to call the [`strapi.utils.models.convertParams` helper](../api-reference/reference.md#strapiutils).
::: note
The returned objects is formatted according to the ORM used by the model.
The returned objects are formatted according to the ORM used by the model.
:::
#### Example
......
......@@ -24,6 +24,8 @@ By default, the [Shadow CRUD](#shadow-crud) feature is enabled and the GraphQL i
Security limits on maximum number of items in your response by default is limited to 100, however you can change this on the following config option `amountLimit`. This should only be changed after careful consideration of the drawbacks of a large query which can cause what would basically be a DDoS (Distributed Denial of Service). And may cause abnormal load on your Strapi server, as well as your database server.
You can also enable the Apollo server tracing feature, which is supported by the playground to track the response time of each part of your query. To enable this feature just change/add the `"tracing": true` option in the GraphQL settings file. You can read more about the tracing feature from Apollo [here](https://www.apollographql.com/docs/engine/features/query-tracing.html).
You can edit these configurations in the following files.
**Path —** `./plugins/graphql/config/settings.json`.
......@@ -31,6 +33,7 @@ You can edit these configurations in the following files.
```
{
"endpoint": "/graphql",
"tracing": false,
"shadowCRUD": true,
"playgroundAlways": false,
"depthLimit": 7,
......
# Internationalization
See the [internationalization' concepts](../concepts/concepts.md#internationalization) for details.
See the [internationalization' concepts](../concepts/concepts.md#internationalization-and-localization) for details.
Because an API may need to send different data based on the language of the user, Strapi provides a built-in strategy to handle the internationalization (i18n).
......
......@@ -148,6 +148,17 @@ module.exports = {
}
```
**Example**
```js
// Create a pet
const xhr = new XMLHttpRequest();
xhr.open('POST', '/pets', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
owner: '5c151d9d5b1d55194d3209be' // The id of the user you want to link
}));
```
### One-to-one
Refer to the [one-to-one concept](../concepts/concepts.md#one-to-one) for informations.
......@@ -211,6 +222,17 @@ module.exports = {
}
```
**Example**
```js
// Create an address
const xhr = new XMLHttpRequest();
xhr.open('POST', '/addresses', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
user: '5c151d9d5b1d55194d3209be' // The id of the user you want to link
}));
```
### One-to-many
Refer to the [one-to-many concept](../concepts/concepts.md#one-to-many) for more informations.
......@@ -274,6 +296,25 @@ module.exports = {
}
```
**Examples**
```js
// Create an article
const xhr = new XMLHttpRequest();
xhr.open('POST', '/articles', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
author: '5c151d9d5b1d55194d3209be' // The id of the user you want to link
}));
// Update an article
const xhr = new XMLHttpRequest();
xhr.open('PUT', '/users/5c151d9d5b1d55194d3209be', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
articles: ['5c151d51eb28fd19457189f6', '5c151d51eb28fd19457189f8'] // Set of ALL articles linked to the user (existing articles + new article or - removed article)
}));
```
### Many-to-many
Refer to the [many-to-many concept](../concepts/concepts.md#many-to-many).
......@@ -343,6 +384,17 @@ module.exports = {
}
```
**Example**
```js
// Update a product
const xhr = new XMLHttpRequest();
xhr.open('PUT', '/products/5c151d9d5b1d55194d3209be', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
categories: ['5c151d51eb28fd19457189f6', '5c151d51eb28fd19457189f8'] // Set of ALL categories linked to the product (existing categories + new category or - removed category)
}));
```
### Polymorphic
The polymorphic relationships are the solution when you don't know which kind of model will be associated to your entry. A common use case is an `Image` model that can be associated to many others kind of models (Article, Product, User, etc).
......
......@@ -7,28 +7,36 @@ To facilitate the development of a plugin, we drastically reduce the amount of c
To setup the development environment please **follow the instructions below:**
1. [Fork the repository](https://github.com/strapi/strapi) to your own GitHub account.
2. Clone it to your computer `git clone git@github.com:strapi/strapi.git`.
3. Run `npm run setup` at the root of the directory.
2. Clone it to your computer `git clone git@github.com:strapi/strapi.git`. (or your fork)
3. Run `cd strapi && npm run setup`
You can run `npm run setup:build` to build the plugins' admin (the setup time will be longer)
Create a development project
1. Create a new project `cd .. && strapi new myDevelopmentProject --dev`.
2. `cd myDevelopmentProject && strapi start` To start the strapi project
::: note
If the installation failed, please remove the global packages related to Strapi. The command `npm ls strapi` will help you to find where your packages are installed globally.
:::
## Plugin development Setup
Create a development project
In a new terminal window:
1. Generate a new plugin: `cd /path/to/myDevelopmentProject && strapi generate:plugin my-plugin`
2. Install admin dependencies and build: `cd /admin && npm setup`
3. `npm start`
When finished with plugin modifications:
1. `cd /path/to/myDevelopmentProject && npm run setup ---plugins`
1. Go to a folder on your computer `cd /path/to/my/folder`.
2. Create a new project `strapi new myDevelopmentProject --dev`.
To rebuild plugins:
To generate a new plugin **run the following commands:**
1. In your project folder `cd myDevelopmentProject && strapi generate:plugin my-plugin`.
2. Link the `strapi-helper-plugin` dependency in your project folder `cd pathToMyProject/myDevelopmentProject/plugins/my-plugin && npm link strapi-helper-plugin`.
3. Link the `strapi-helper-plugin` dependency in the `analytics` plugin folder `cd pathToMyProject/myDevelopmentProject/plugins/analytics && npm link strapi-helper-plugin`.
4. Start the server in the admin folder `cd pathToMyProject/myDevelopmentProject/admin && npm start` and go to the following url [http://localhost:4000/admin](http://localhost:4000/admin).
5. In a new terminal window open at the root of your project launch your Strapi server `strapi start`.
Run this inside the cloned or forked repo of `strapi`
1. `cd strapi && npm run setup:build`
Your are now ready to develop your own plugin and live-test your updates!
Your are now ready to develop your own plugin and live-test your updates! The working local URI should be localhost:4000/admin.
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
......@@ -226,6 +226,7 @@ module.exports = (scope, cb) => {
}
let cmd = `${packageCmd} ${scope.client.connector}@${scope.strapiPackageJSON.version}`;
let linkNodeModulesCommand = `cd ${scope.tmpPath} && npm link ${scope.client.connector}`;
if (scope.client.module) {
cmd += ` ${scope.client.module}`;
......@@ -233,6 +234,7 @@ module.exports = (scope, cb) => {
if (scope.client.connector === 'strapi-hook-bookshelf') {
cmd += ` strapi-hook-knex@${scope.strapiPackageJSON.version}`;
linkNodeModulesCommand += ` && npm link strapi-hook-knex`;
scope.additionalsDependencies = ['strapi-hook-knex', 'knex'];
}
......@@ -248,7 +250,13 @@ module.exports = (scope, cb) => {
}
}
resolve();
if (scope.developerMode) {
exec(linkNodeModulesCommand, () => {
resolve();
});
} else {
resolve();
}
});
})
];
......@@ -258,8 +266,8 @@ module.exports = (scope, cb) => {
try {
require(path.join(`${scope.tmpPath}`, '/node_modules/', `${scope.client.connector}/lib/utils/connectivity.js`))(scope, cb.success, connectionValidation);
} catch(err) {
shell.rm('-r', scope.tmpPath);
console.log(err);
shell.rm('-r', scope.tmpPath);
cb.error();
}
});
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
'use strict';
// Core
const path = require('path');
// Public node modules
const inquirer = require('inquirer');
const rimraf = require('rimraf');
module.exports = (scope, success, error) => {
// eslint-disable-next-line import/no-unresolved
const knex = require('knex')({
let knex;
try {
// eslint-disable-next-line import/no-unresolved
knex = require('knex');
} catch (err) {
// eslint-disable-next-line import/no-unresolved
knex = require(path.resolve(scope.tmpPath, 'node_modules', 'knex'));
}
knex = knex({
client: scope.client.module,
connection: Object.assign({}, scope.database.settings, {
user: scope.database.settings.username
......@@ -52,10 +64,16 @@ module.exports = (scope, success, error) => {
})
.catch((err) => {
if (err.sql) {
console.log('⚠️ Server connection has failed! Make sure your database server is running.');
console.log('⚠️ Server connection has failed! Make sure your database server is running.');
} else {
console.log(`⚠️ Database connection has failed! Make sure your "${scope.database.settings.database}" database exist.`);
console.log(`⚠️ Database connection has failed! Make sure your "${scope.database.settings.database}" database exist.`);
}
if (scope.debug) {
console.log('🐛 Full error log:');
console.log(err);
}
error();
});
};
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
......@@ -29,7 +29,13 @@ module.exports = (scope, success, error) => {
Mongoose.connect(`mongodb${srv ? '+srv' : ''}://${scope.database.settings.host}${!srv ? `:${scope.database.settings.port}` : ''}/`, connectOptions, function (err) {
if (err) {
console.log('⚠️ Database connection has failed! Make sure your database is running.');
console.log('⚠️ Database connection has failed! Make sure your database is running.');
if (scope.debug) {
console.log('🐛 Full error log:');
console.log(err);
}
return error();
}
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
{
"endpoint": "/graphql",
"tracing": false,
"shadowCRUD": true,
"playgroundAlways": false,
"depthLimit": 7,
......
......@@ -162,6 +162,7 @@ module.exports = strapi => {
context: ctx,
}),
validationRules: [depthLimit(strapi.plugins.graphql.config.depthLimit)],
tracing: _.get(strapi.plugins.graphql, 'config.tracing', false),
playground: false,
};
......
Copyright (c) 2018 Nikolay Tsenkov (nikolay@tsenkov.net).
Copyright (c) 2019 Nikolay Tsenkov (nikolay@tsenkov.net).
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Copyright (c) 2017, Vandium Software Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2015-2019 Strapi Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
......
......@@ -42,7 +42,8 @@ module.exports = function (name, cliArguments) {
generatorType: 'new',
name,
strapiPackageJSON: packageJSON,
developerMode
developerMode,
debug: cliArguments.debug !== undefined
};
const dbArguments = ['dbclient', 'dbhost', 'dbport', 'dbname', 'dbusername', 'dbpassword'];
......
......@@ -53,6 +53,7 @@ program
program
.command('new')
.option('-d, --dev', 'Development mode')
.option('--debug', 'Display database connection error')
.option('--dbclient <dbclient>', 'Database client')
.option('--dbhost <dbhost>', 'Database host')
.option('--dbport <dbport>', 'Database port')
......
......@@ -16,7 +16,7 @@ module.exports = strapi => {
* Initialize the hook
*/
initialize: function(cb) {
initialize: function (cb) {
strapi.app.use(
async (ctx, next) => {
if (ctx.request.admin) {
......@@ -31,7 +31,17 @@ module.exports = strapi => {
})(ctx, next);
} else if (strapi.config.currentEnvironment.security.cors.enabled) {
return strapi.koaMiddlewares.kcors({
origin: strapi.config.middleware.settings.cors.origin,
origin: function (ctx) {
const whitelist = strapi.config.middleware.settings.cors.origin.split(/\s*,\s*/);
const requestOrigin = ctx.accept.headers.origin;
if (whitelist.includes('*')) {
return '*';
}
if (!whitelist.includes(requestOrigin)) {
return ctx.throw(`${requestOrigin} is not a valid origin`);
}
return requestOrigin;
},
exposeHeaders: strapi.config.middleware.settings.cors.expose,
maxAge: strapi.config.middleware.settings.cors.maxAge,
credentials: strapi.config.middleware.settings.cors.credentials,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册