Skip to content

Commit 967f9fc

Browse files
authored
Merge pull request #27 from Human-Connection/13-create-initial-api-keys
Create initial api keys
2 parents b822a26 + 20cef3f commit 967f9fc

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ To run the Docker version, follow these steps:
107107
and open the directory in the console. Then run `git clone https://github.com/Human-Connection/Clock-of-Change-API.git` to clone the repository to this directory.
108108
2. Go to the newly created Clock-of-Change-API directory (`cd Clock-of-Change-API` in the console)
109109
3. Run `docker-compose up`. This will build the Docker container on first startup and run it. This can take a while, but after some time you should see the Clock of Change ticking.
110+
4. To create an initial API key and sample entries, run `docker-compose exec db seed.sh`. The initial API key you can use with your requests will have the value `secret`.
110111

111112
Now the Clock of Change API server is ready for usage at [http://127.0.0.1:1337](http://127.0.0.1:1337)
112113

docker-compose.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ version: '3'
33
services:
44
db:
55
image: mysql:5
6+
volumes:
7+
- coc_api_dbdata:/var/lib/mysql
8+
- ./seed.sh:/usr/local/bin/seed.sh
69
environment:
7-
MYSQL_ROOT_PASSWORD: 123456
10+
MYSQL_ROOT_PASSWORD: clockofchangepw
811
MYSQL_DATABASE: clock_of_change
12+
MYSQL_USER: coc
13+
MYSQL_PASSWORD: 123456
914
ports:
10-
- 3306:3306
15+
- 3306:3306
1116

1217
mailhog:
1318
container_name: mailhog
@@ -21,14 +26,14 @@ services:
2126
build:
2227
context: .
2328
volumes:
24-
- ".:/home/node/coc-api"
25-
- "/home/node/coc-api/node_modules"
29+
- .:/home/node/coc-api
30+
- /home/node/coc-api/node_modules
2631
ports:
2732
- 1337:1337
2833
environment:
2934
- MYSQL_HOST=db
3035
- MYSQL_DB=clock_of_change
31-
- MYSQL_USER=root
36+
- MYSQL_USER=coc
3237
- MYSQL_PASS=123456
3338
- MAIL_HOST=mailhog
3439
- MAIL_PORT=1025
@@ -38,3 +43,6 @@ services:
3843
- db
3944
- mailhog
4045
command: bash -c "wait-on tcp:db:3306 && db-migrate up && npm run start"
46+
47+
volumes:
48+
coc_api_dbdata:

seed.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD $MYSQL_DATABASE << EOF
3+
INSERT INTO \`clock_of_change\`.\`apikeys\` (\`secret\`, \`valid\`) VALUES ('secret', '1');
4+
INSERT INTO \`clock_of_change\`.\`entries\` (\`firstname\`, \`lastname\`, \`email\`, \`country\`, \`message\`, \`confirm_key\`, \`beta\`, \`newsletter\`, \`pax\`, \`email_confirmed\`, \`status\`) VALUES ('Pamela', 'Musterfrau', 'pamela@example.org', 'US', 'Let us change the world!', 'confirm', '1', '0', '1', '1', '1');
5+
INSERT INTO \`clock_of_change\`.\`entries\` (\`firstname\`, \`lastname\`, \`email\`, \`country\`, \`message\`, \`confirm_key\`, \`beta\`, \`newsletter\`, \`pax\`, \`email_confirmed\`, \`status\`) VALUES ('Max', 'Mustermann', 'max@example.org', 'DE', 'Lasst uns die Welt verbessern!', 'confirm', '0', '1', '1', '1', '1');
6+
EOF

0 commit comments

Comments
 (0)