|
|
@@ -12,10 +12,34 @@ weight: 0
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
+The following instructions describe how to run a development instance of Vendure using ts-node and a MySQL / MariaDB server
|
|
|
+
|
|
|
+### Set up the database
|
|
|
+
|
|
|
+You'll need a database server available from your local machine. For example, [this MariaDB & phpMyAdmin Docker image](https://github.com/bitnami/bitnami-docker-phpmyadmin) can be used. Create a new database and name it e.g. "vendure".
|
|
|
+
|
|
|
+You'll also need a driver for Vendure to connect to the database. In this case, the `mysql` package.
|
|
|
+
|
|
|
+```bash
|
|
|
+$ npm install mysql --save
|
|
|
+```
|
|
|
+
|
|
|
+### Install ts-node
|
|
|
+
|
|
|
+This allows us to run TypeScript directly without a compilation step. Useful for development.
|
|
|
+
|
|
|
+```bash
|
|
|
+$ npm install --save-dev ts-node
|
|
|
+```
|
|
|
+
|
|
|
+### Install Vendure
|
|
|
+
|
|
|
```bash
|
|
|
$ npm install --save @vendure/core
|
|
|
```
|
|
|
|
|
|
+### Initialize with the Vendure CLI
|
|
|
+
|
|
|
Vendure includes a CLI program which can generate the initial configuration and entry file for your server:
|
|
|
|
|
|
```bash
|
|
|
@@ -24,41 +48,22 @@ $ npx vendure init
|
|
|
|
|
|
The init command will ask a series of questions which allow the CLI to generate a configuration and index file.
|
|
|
|
|
|
-```bash
|
|
|
-$ ts-node index
|
|
|
-```
|
|
|
+### Run
|
|
|
+
|
|
|
+Once the init script has completed, the server can be started.
|
|
|
|
|
|
-or if using JavaScript:
|
|
|
```bash
|
|
|
-$ node index
|
|
|
+$ ts-node index
|
|
|
```
|
|
|
|
|
|
-## Making a request
|
|
|
+Assuming the default config settings, you can now access:
|
|
|
|
|
|
-When making an API request, it must include a `vendure-token` header with the value being the channel token of the active channel. This value is set in the config by the `defaultChannelToken` property. If this is not set, or does not match a valid channel token, you will get the error `No valid channel was specified`.
|
|
|
+* The Vendure GraphQL API: [http://localhost:3000/api](http://localhost:3000/api)
|
|
|
+* The Vendure Admin UI: [http://localhost:3000/admin](http://localhost:3000/admin)
|
|
|
|
|
|
-For example:
|
|
|
-```TypeScript
|
|
|
-// index.ts
|
|
|
-bootstrap({
|
|
|
- port: 3000,
|
|
|
- apiPath: 'api',
|
|
|
- defaultChannelToken: 'default-channel'
|
|
|
- // ...
|
|
|
-});
|
|
|
-```
|
|
|
+{{% alert primary %}}
|
|
|
+Log in with the superadmin credentials:
|
|
|
|
|
|
-```TypeScript
|
|
|
-// API call
|
|
|
-fetch(
|
|
|
- 'http://localhost:3000/api',
|
|
|
- {
|
|
|
- headers: {
|
|
|
- 'content-type': 'application/json',
|
|
|
- 'vendure-token': 'default-channel',
|
|
|
- },
|
|
|
- body: '{"query":"mutation { login(username: \\"superadmin\\", password: \\"superadmin\\") { user { id } } }"}',
|
|
|
- method: 'POST',
|
|
|
- },
|
|
|
-);
|
|
|
-```
|
|
|
+* **username**: superadmin
|
|
|
+* **password**: superadmin
|
|
|
+{{% /alert %}}
|