-
Notifications
You must be signed in to change notification settings - Fork 128
TSGuild-99: Create a TypeScript version of election-api-javascript #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rossanodan
wants to merge
12
commits into
bbc:main
Choose a base branch
from
rossanodan:TSGuild-99
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d28d8ec
TSGuild-99 set up TypeScript project for election-api-javascript
f5bea88
TSGuild-99 set up Jest configuration for TypeScript and copy the test…
643874f
TSGuild-99 Copy README and tasks with interview instructions
65b7e52
Update election-api-typescript/package.json
5b43fdb
Update election-api-typescript/package.json
e63c61c
Update election-api-typescript/package.json
469007b
Update election-api-typescript/src/resultsController.ts
f49fd1c
TSGuild-99 return null and a message to terminal when adding data to …
98d3271
TSGuild-99 fix return type function getResult
4cc9750
Update election-api-typescript/jest.config.ts
2f89403
TSGuild-99 installed and used ts-node-dev to startup the local server
802cb54
TSGuild-99 add noImplicitAny to tsconfig rules
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## Description | ||
|
||
If you are not familiar with how elections work in the UK, please see this short BBC video https://www.youtube.com/watch?v=cRxUhGetEPQ | ||
|
||
The results API presents a simple elections result service. | ||
|
||
### Domain | ||
|
||
The domain for the election represents some key concepts: | ||
|
||
- _**constituencyId**_ a unique integer id to identify a location. E.g "Brent Central" is 90 | ||
- _**party**_ is a short 3, or 4, letter code for a party for instance LAB = Labour, CON = Conservative etc. | ||
- _**votes**_ the number of votes gained by a party in a constituency | ||
- _**share**_ the % share of the total votes the party received | ||
|
||
### API | ||
|
||
The API has 3 endpoints: | ||
|
||
- GET `/result/{id}` to get an elections result for a given id. | ||
- POST `/result` to add a new result | ||
- GET `/scoreboard` to get the running totals. This is unimplemented. | ||
|
||
## Setup | ||
|
||
Requires: | ||
|
||
- node (18) - available from https://nodejs.org/en/download/ | ||
- npm - will be installed with node, or see https://docs.npmjs.com/downloading-and-installing-node-js-and-npm | ||
|
||
``` | ||
npm install | ||
npm start | ||
``` | ||
|
||
If you need to run it on another port, instead of `npm start`, you can run the below, where 9000 is swapped for your preferred port: | ||
|
||
```bash | ||
PORT=9000 npm start | ||
``` | ||
|
||
At this point we don't ask you to do any more until your booked assessment time. | ||
|
||
You're ready for your assessment as long as the following are true: | ||
|
||
- You can open this folder in your preferred code editor | ||
- You can run all the tests with `npm test` and all 4 pass | ||
- You can run `npm start` without any errors and http://localhost:3000/ returns "Cannot GET /" | ||
|
||
:warning: If you make any changes to the code, please ensure you return it to it's initial (HEAD) state before your assessment. | ||
|
||
## Assessment Time | ||
|
||
During your assessment we will ask you to work though the task in `tasks.md` with a pair. Please do not work on or complete these prior to the assessment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Config } from "@jest/types"; | ||
|
||
const config: Config.InitialOptions = { | ||
verbose: true, | ||
preset: "ts-jest", | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.