Skip to content

Commit 6294a83

Browse files
authored
Merge pull request #179 from sproogen/develop
Release 2.4
2 parents a272dfa + fdd579d commit 6294a83

File tree

337 files changed

+27660
-20480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+27660
-20480
lines changed

.env.dist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This file is a "template" of which env vars need to be defined for your application
2+
# Copy this file to .env file for development, create environment variables when deploying to production
3+
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4+
5+
###> symfony/framework-bundle ###
6+
APP_ENV=dev
7+
APP_SECRET=a657a6141f77915fe542447c9a996a4a
8+
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
9+
#TRUSTED_HOSTS=localhost,example.com
10+
###< symfony/framework-bundle ###
11+
12+
###> doctrine/doctrine-bundle ###
13+
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
14+
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
15+
# Configure your db driver and server_version in config/packages/doctrine.yaml
16+
# DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name
17+
###< doctrine/doctrine-bundle ###
18+
19+
###> lexik/jwt-authentication-bundle ###
20+
# Key paths should be relative to the project directory
21+
JWT_PASSPHRASE=SuperSecretPassword
22+
###< lexik/jwt-authentication-bundle ###

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APP_ENV=test

.gitignore

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
1-
# Cache and logs (Symfony2)
2-
/app/cache/*
3-
/app/logs/*
4-
!app/cache/.gitkeep
5-
!app/logs/.gitkeep
6-
7-
# Cache and logs (Symfony3)
8-
/var/*
9-
!/var/cache
10-
/var/cache/*
11-
!var/cache/.gitkeep
12-
!/var/logs
13-
/var/logs/*
14-
!var/logs/.gitkeep
15-
!/var/sessions
16-
/var/sessions/*
17-
!var/sessions/.gitkeep
18-
!var/SymfonyRequirements.php
19-
!/var/jwt
20-
/var/jwt/*
21-
!var/jwt/.gitkeep
22-
23-
# Parameters
24-
/app/config/parameters.yml
25-
/app/config/parameters.ini
26-
/app/config/parameters_dev.yml
27-
/app/config/parameters.php
28-
291
# Managed by Composer
30-
/app/bootstrap.php.cache
31-
/var/bootstrap.php.cache
322
/bin/*
333
!bin/console
344
!bin/symfony_requirements
355
/vendor/
366

37-
# Assets and user uploads
38-
/web/bundles/
39-
/web/uploads/
40-
41-
# PHPUnit
42-
/app/phpunit.xml
43-
/phpunit.xml
44-
457
# Phplint
468
.phplint-cache
479

@@ -66,6 +28,26 @@ npm-debug.log*
6628
node_modules
6729

6830
#React Files
69-
/web/client/
70-
/app/Resources/views/react/index.html
71-
/client/
31+
/public/client/
32+
33+
webpack-stats.json
34+
35+
###> lexik/jwt-authentication-bundle ###
36+
/config/jwt/*.pem
37+
###< lexik/jwt-authentication-bundle ###
38+
39+
###> phpunit/phpunit ###
40+
/phpunit.xml
41+
###< phpunit/phpunit ###
42+
43+
###> symfony/phpunit-bridge ###
44+
.phpunit
45+
/phpunit.xml
46+
###< symfony/phpunit-bridge ###
47+
48+
###> symfony/framework-bundle ###
49+
/.env
50+
/public/bundles/
51+
/var/
52+
/vendor/
53+
###< symfony/framework-bundle ###

.jshintrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.travis.yml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
1+
sudo: required
2+
dist: trusty
3+
14
language: php
25

36
php:
4-
- 5.6
7+
- '7.2'
58

69
services:
710
- mysql
811

912
env:
10-
- NODE_VERSION="7"
13+
- NODE_VERSION=8 APP_ENV=test
1114

1215
cache:
1316
directories:
1417
- $HOME/.composer/cache/file
1518
- vendor
16-
- node_modules
19+
- app/node_modules
1720

1821
branches:
1922
only:
2023
- master
2124
- develop
2225

2326
before_install:
24-
- cp app/config/parameters.yml.travis app/config/parameters.yml
27+
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $NODE_VERSION && nvm install-latest-npm
2528

2629
install:
27-
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $NODE_VERSION
2830
- composer install
29-
- npm install
31+
- (cd app && npm ci)
3032

3133
before_script:
32-
- php bin/console doctrine:database:create --env=test
33-
- composer compile-test
34+
- php bin/console doctrine:database:create
35+
- composer compile
3436

3537
script:
36-
- bin/phpcs --standard=PSR2 src/
37-
- bin/phplint src
38-
- bin/phpunit
39-
- SYMFONY_DEPRECATIONS_HELPER=disabled bin/codecept run --ext DotReporter
40-
- npm run lint
41-
- npm run test
38+
- vendor/bin/phpcs --standard=PSR2 --ignore=Migrations src/
39+
- vendor/bin/phplint src
40+
- vendor/bin/simple-phpunit
41+
- SYMFONY_DEPRECATIONS_HELPER=disabled vendor/bin/codecept run
42+
- (cd app && npm run build)
43+
- (cd app && npm run lint)
44+
- (cd app && npm run test -- --coverage --ci)
4245

4346
after_script:
44-
- bin/codacycoverage clover build/logs/clover.xml
45-
- cat build/coverage/lcov.info | node_modules/.bin/codacy-coverage .
47+
- vendor/bin/codacycoverage clover build/coverage/clover.xml
48+
- (cd app && cat build/coverage/lcov.info | node_modules/.bin/codacy-coverage .)
4649

4750
notifications:
4851
email:

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: bin/heroku-php-apache2 web/
1+
web: $(composer config bin-dir)/heroku-php-apache2 public/

Procfile.dev

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 82 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,60 @@
11
# itsgoingto.be [![Build Status](https://travis-ci.org/sproogen/itsgoingto.be.svg)](https://travis-ci.org/sproogen/itsgoingto.be) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/95ef266848d44348a421142d2ed6f8cb)](https://www.codacy.com/app/sproogen/itsgoingto.be?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=sproogen/itsgoingto.be&amp;utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/95ef266848d44348a421142d2ed6f8cb)](https://www.codacy.com/app/sproogen/itsgoingto.be?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=sproogen/itsgoingto.be&amp;utm_campaign=Badge_Coverage)
22

3-
Symfony and React magic behind itsgoingto.be
3+
Symfony and React magic behind [itsgoingto.be]
44

5-
The root of this project contains the Symfony app.
5+
The root of this project contains the Symfony app which provides the API.
66

7-
The React app can be found at app/Resources/client. This can been loaded through symfony for developing or compiled into the web folder for prodcution builds.
7+
The React app can be found in the `app` folder. During development this is loaded through a route in symfony to provide the Symfony debug toolbar.
8+
In production the app is loaded from compiled files from the public folder via the `.htaccess`
89

9-
There are a number of number of NPM scripts that can be run from the project root.
10+
Getting started
11+
-------------
12+
You will need to have [Docker] installed and running, also make sure you have PHP 7.2 or higher and [Composer] installed.
13+
14+
Clone the repository into a local folder.
15+
16+
Now inside the project folder run
17+
```
18+
composer install
19+
./build.sh
20+
docker-compose up
21+
```
22+
23+
You will now be able to access the app at `http://localhost:8000` and storybook at `http://localhost:6006`.
24+
Everytime you make a change to the app or storybook stories the app will automatically rebuild and refresh in the browser.
25+
26+
Running tests
27+
-------------
28+
###### Client
29+
To test the React client, run the folowwing from inside the `app` folder.
30+
31+
`npm run lint` to run the js linter.
32+
`npm run test` to run all the unit tests using jest.
33+
34+
###### API
35+
To test the Symfony API, from the following from inside the root of the project.
36+
37+
`vendor/bin/phplint src` to run the php linter.
38+
`vendor/bin/phpunit` to run the unit tests.
39+
`vendor/bin/codecept run` to run the API end-to-end functional tests.
1040

1141
API
1242
-------------
13-
Retrieve Polls: [```GET /api/polls```](#retrieve-polls)
43+
[```GET /api/polls```](#retrieve-polls) - Retrieve Polls
1444

15-
Retrieve a Poll: [```GET /api/polls/:identifier```](#retrieve-a-poll)
45+
[```POST /api/polls```](#create-a-poll) - Create a Poll
1646

17-
Create a Poll: [```POST /api/polls```](#create-a-poll)
47+
[```GET /api/polls/:identifier```](#retrieve-a-poll) - Retrieve a Poll
1848

19-
Delete a Poll: [```DELETE /api/polls/:identifier```](#delete-a-poll)
49+
[```DELETE /api/polls/:identifier```](#delete-a-poll) - Delete a Poll
2050

21-
Retrieve responses info: [```GET /api/polls/:identifier/responses```](#retrieve-responses-info)
51+
[```GET /api/polls/:identifier/responses```](#retrieve-responses-info) - Retrieve responses info
2252

23-
Submit/Change users response: [```POST /api/polls/:identifier/responses```](#submitchange-a-user-response)
53+
[```POST /api/polls/:identifier/responses```](#submitchange-a-user-response) - Submit/Change users response
2454

25-
Login: [```POST /api/login```](#login)
55+
[```POST /api/login```](#login) - Login
56+
57+
[```GET /api/stats```](#retrieve-stats) - Stats
2658

2759
#### Retrieve Polls
2860
Only returns polls if the user has `ROLE_ADMIN`
@@ -79,11 +111,17 @@ GET /api/polls
79111
}
80112
```
81113

82-
#### Retrieve a Poll
83-
Only returns a non deleted poll unless the user has `ROLE_ADMIN`
114+
#### Create a Poll
84115
```
85-
GET /api/polls/:identifier
116+
POST /api/polls
86117
```
118+
###### Input
119+
| Name | Type | Required | Description |
120+
| ---- | ---- | -------- | ----------- |
121+
| question | string | true | The question text.
122+
| answers | array | true | Array of answers for the poll. Each answer should be a string |
123+
| multipleChoice | boolean | false | Is the poll multiple choice. Default: false |
124+
| endDate | string | false | The end date for the poll. Format: DateTime::ATOM (e.g. 2017-05-18T15:52:01+00:00). Default: null |
87125
###### Example Response
88126
```
89127
{
@@ -116,7 +154,7 @@ GET /api/polls/:identifier
116154
"type": "Poll",
117155
"id": 1
118156
},
119-
"responsesCount": 2
157+
"responsesCount": 0
120158
},
121159
{
122160
"id": 2,
@@ -125,27 +163,19 @@ GET /api/polls/:identifier
125163
"type": "Poll",
126164
"id": 1
127165
},
128-
"responsesCount": 3
166+
"responsesCount": 0
129167
}
130168
],
131-
"userResponses" : [
132-
2
133-
],
134-
"responsesCount": 5
169+
"userResponses": [],
170+
"responsesCount": 0
135171
}
136172
```
137173

138-
#### Create a Poll
174+
#### Retrieve a Poll
175+
Only returns a non deleted poll unless the user has `ROLE_ADMIN`
139176
```
140-
POST /api/polls
177+
GET /api/polls/:identifier
141178
```
142-
###### Input
143-
| Name | Type | Required | Description |
144-
| ---- | ---- | -------- | ----------- |
145-
| question | string | true | The question text.
146-
| answers | array | true | Array of answers for the poll. Each answer should be a string |
147-
| multipleChoice | boolean | false | Is the poll multiple choice. Default: false |
148-
| endDate | string | false | The end date for the poll. Format: DateTime::ATOM (e.g. 2017-05-18T15:52:01+00:00). Default: null |
149179
###### Example Response
150180
```
151181
{
@@ -178,7 +208,7 @@ POST /api/polls
178208
"type": "Poll",
179209
"id": 1
180210
},
181-
"responsesCount": 0
211+
"responsesCount": 2
182212
},
183213
{
184214
"id": 2,
@@ -187,11 +217,13 @@ POST /api/polls
187217
"type": "Poll",
188218
"id": 1
189219
},
190-
"responsesCount": 0
220+
"responsesCount": 3
191221
}
192222
],
193-
"userResponses": [],
194-
"responsesCount": 0
223+
"userResponses" : [
224+
2
225+
],
226+
"responsesCount": 5
195227
}
196228
```
197229

@@ -322,6 +354,19 @@ POST /api/login
322354
}
323355
```
324356

357+
#### Retrieve Stats
358+
Only returns stats if the user has `ROLE_ADMIN`
359+
```
360+
GET /api/stats
361+
```
362+
###### Example Response
363+
```
364+
{
365+
'polls': 156,
366+
'responses': 549
367+
}
368+
```
369+
325370
Copyright
326371
-------------
327372
```
@@ -344,3 +389,7 @@ GNU General Public License for more details.
344389
You should have received a copy of the GNU General Public License
345390
along with ItsGoingToBe. If not, see <http://www.gnu.org/licenses/>.
346391
```
392+
393+
[itsgoingto.be]: http://itsgoingto.be/
394+
[Docker]: https://docs.docker.com/get-started/
395+
[Composer]: https://getcomposer.org/

app.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
"name": "itsgoingto.be",
33
"scripts": {},
44
"env": {
5-
"JAWSDB_URL": {
5+
"DATABASE_URL": {
66
"required": true
77
},
8-
"SYMFONY_ENV": {
8+
"APP_ENV": {
99
"required": true
1010
},
11-
"SECRET": {
11+
"APP_SECRET": {
1212
"required": true
1313
},
14-
"JWT_PASS_PHRASE": {
14+
"JWT_PASSPHRASE": {
1515
"required": true
1616
}
1717
},

app/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

0 commit comments

Comments
 (0)