This repository has been archived by the owner on Oct 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9a3b94a
Showing
20 changed files
with
10,161 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
# Visual Studio Code config file | ||
.vscode | ||
|
||
# Node dependencies | ||
node_modules | ||
|
||
# Log files | ||
*.log | ||
|
||
# Istanbul/nyc code coverage results | ||
coverage | ||
.nyc_output | ||
|
||
# linter config files | ||
.eslintrc.json | ||
|
||
# Jenkins | ||
JenkinsFile* |
This file contains 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,27 @@ | ||
language: node_js | ||
node_js: | ||
- "8.9.1" | ||
|
||
stages: | ||
- security-tests | ||
- unit-tests | ||
|
||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
- script: | ||
- npm outdated | ||
|
||
jobs: | ||
include: | ||
- stage: security-tests | ||
script: | ||
- npm outdated | ||
|
||
- stage: security-tests | ||
script: | ||
- npm run security | ||
|
||
- stage: unit-tests | ||
script: | ||
- npm run test |
This file contains 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,6 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
|
||
|
||
|
This file contains 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,99 @@ | ||
# Contributing | ||
|
||
We're glad you want to contribute to this project! This document will help answer common questions you may have during your first contribution. | ||
|
||
## Submitting Issues | ||
|
||
Not every contribution comes in the form of code. Submitting, confirming, and triaging issues is an important task for any project. | ||
|
||
If you are familiar with DWP and know the component that is causing you a problem, you can file an issue in the corresponding GitHub project. All of our Open Source Software can be found in our [GitHub organization](https://github.com/dwp/). | ||
|
||
We ask you not to submit security concerns via GitHub. For details on submitting potential security issues please contact [[email protected]](mailto:[email protected]) | ||
|
||
## Contribution Process | ||
|
||
We have a 3 step process for contributions: | ||
|
||
1. Fork our repo and commit changes to a new branch based off `master`, making sure to sign-off those changes for the [Developer Certificate of Origin](#developer-certification-of-origin-dco). | ||
2. Create a GitHub Pull Request for your change, following the instructions in the pull request template (if present). | ||
3. A [Code Review](#code-review-process) will then be undertaken by the project maintainers. | ||
|
||
### Pull Request Requirements | ||
|
||
Our projects are built to last. We strive to ensure high quality throughout the experience. In order to ensure this, we require that all pull requests to DWP projects meet these specifications: | ||
|
||
1. **Tests:** To ensure high quality code and protect against future regressions, we require all the code in DWP Projects to have at least unit test coverage. | ||
2. **Green CI Tests:** We use CI systems to test all pull requests, although not all of these are publicly visible. We require these test runs to succeed on every pull request before being merged. Project maintainers will help guide you if they find any issues. | ||
|
||
### Code Review Process | ||
|
||
Code review for public contributions takes place in GitHub pull requests. See [this article](https://help.GitHub.com/articles/about-pull-requests/) if you're not familiar with GitHub Pull Requests. | ||
|
||
Once you open a pull request, project maintainers will review your code and respond to your pull request with any feedback they might have. The process at this point is as follows: | ||
|
||
1. Two thumbs-up (:+1:) are required from project maintainers. | ||
2. When ready, your pull request will be tagged with label `Ready For Merge`. | ||
3. Your change will be merged into the project's `master` branch and may be noted in the project's `CHANGELOG.md` at the time of release. | ||
|
||
### Developer Certification of Origin (DCO) | ||
|
||
Licensing is very important to open source projects. It helps ensure the software continues to be available under the terms that the author desired. | ||
|
||
This project uses [the ISC license](LICENSE) to strike a balance between open contribution and allowing you to use the software however you would like to. | ||
|
||
The license tells you what rights you have that are provided by the copyright holder. It is important that the contributor fully understands what rights they are licensing and agrees to them. Sometimes the copyright holder isn't the contributor, such as when the contributor is doing work on behalf of a company. | ||
|
||
To make a good faith effort to ensure these criteria are met, DWP requires the Developer Certificate of Origin (DCO) process to be followed. | ||
|
||
The DCO is an attestation attached to every contribution made by every developer. In the commit message of the contribution, the developer simply adds a Signed-off-by statement and thereby agrees to the DCO, which you can find below or at <http://developercertificate.org/>. | ||
|
||
``` | ||
Developer's Certificate of Origin 1.1 | ||
By making a contribution to this project, I certify that: | ||
(a) The contribution was created in whole or in part by me and I | ||
have the right to submit it under the open source license | ||
indicated in the file; or | ||
(b) The contribution is based upon previous work that, to the | ||
best of my knowledge, is covered under an appropriate open | ||
source license and I have the right under that license to | ||
submit that work with modifications, whether created in whole | ||
or in part by me, under the same open source license (unless | ||
I am permitted to submit under a different license), as | ||
Indicated in the file; or | ||
(c) The contribution was provided directly to me by some other | ||
person who certified (a), (b) or (c) and I have not modified | ||
it. | ||
(d) I understand and agree that this project and the contribution | ||
are public and that a record of the contribution (including | ||
all personal information I submit with it, including my | ||
sign-off) is maintained indefinitely and may be redistributed | ||
consistent with this project or the open source license(s) | ||
involved. | ||
``` | ||
|
||
#### DCO Sign-Off Methods | ||
|
||
The DCO requires a sign-off message in the following format appear on each commit in the pull request: | ||
|
||
``` | ||
Signed-off-by: Jane Doe <[email protected]> | ||
``` | ||
|
||
The DCO text can either be manually added to your commit body, or you can add either **-signoff** or **-s** to your usual git commit commands. If you forget to add the sign-off you can also amend a previous commit with the sign-off by running **git commit –-amend --signoff --no-edit**. If you've pushed your changes to GitHub already you'll need to force push your branch after this with **git push --force**. | ||
|
||
## Versioning | ||
|
||
We follow the [Semantic Versioning](http://semver.org/) standard. Our standard version numbers look like X.Y.Z which mean: | ||
|
||
* X is a major release, which may not be fully compatible with any prior major releases | ||
* Y is a minor release, which adds both new features and bug fixes | ||
* Z is a patch release, which just adds bug fixes | ||
|
||
## Acknowledgements | ||
|
||
This guide was originally based upon the [InSpec Contribution Guide](https://github.com/chef/inspec/blob/master/CONTRIBUTING.md). |
This file contains 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,15 @@ | ||
ISC License (ISC) | ||
|
||
Copyright 2017, 2018 Crown Copyright (Department for Work and Pensions) | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. |
This file contains 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,142 @@ | ||
# get-uk-state-pension-date # | ||
|
||
This package can be used in two different ways. | ||
|
||
1) Installed from a GitLab repository, as a dependency in your package.json file. | ||
|
||
2) Cloned from the repository to provide a simple REST based service. | ||
|
||
|
||
## 1) Package dependency | ||
|
||
This package, provides two simple functions that allows the calculation of the | ||
Date on which a UK citizen becomes elligible for their State Pension. | ||
|
||
The functions are... | ||
|
||
```javascript | ||
getStatePensionDate(dateOfBirth, gender) | ||
getStatePensionDateAsString(dateOfBirth, gender) | ||
``` | ||
|
||
Where... | ||
|
||
* 'dateOfBirth' must be in the YYYY-MM-DD format. | ||
* 'gender' must be one of 'F', 'FEMALE', 'M' or 'MALE' (case insensitive). | ||
* YYYY-MM-DD is the only format supported. | ||
* The YYYY section of the Date of Birth must be in the range 1000 - 4000 (Arbitrary limits imposed by author). | ||
* The 'getStatePensionDate' function returns a Date object representing the State Pension Date. | ||
* The 'getStatePensionDateAsString' function returns a String containing the State Pension Date in the YYYY-MM-DD format. | ||
* If the input provided is invalid the function will throw TypeError('Invalid Input'). | ||
* If the State Pension Date cannot be determined, a value of 'undefined' will be returned (by both functions). | ||
* Invalid date values (e.g. 29 feb in non-leap years, or 31 April etc.) will result in 'undefined' being returned (by both functions). | ||
* Invalid gender values (anything other than 'F', 'FEMALE', 'M' or 'MALE') will result in 'undefined' being returned (by both functions). | ||
|
||
## Example | ||
|
||
Install by cloning this repository and running `npm install`. Once installed, then the functions can simply be required within a Javascrip file | ||
as follows... | ||
|
||
```javascript | ||
// Require the module | ||
const UKStatePension = require('get-uk-state-pension-date'); | ||
|
||
const getUkStatePensionDate = UKStatePension.getUkStatePensionDate; | ||
const getUkStatePensionDateAsString = UKStatePension.getUkStatePensionDateAsString; | ||
|
||
// Get state pension date for a male born on 25 March 1990 | ||
const pensionDate = getUkStatePensionDate('1990-03-25', 'M'); | ||
|
||
// Write result to console | ||
console.log(`For a male born on 25 March 1990, their state Pension Date would be ${pensionDate}`); | ||
|
||
// Get the same item as a string in the YYYY-MM-DD format | ||
const pensionDateString = getUkStatePensionDateAsString('1990-03-25', 'M'); | ||
|
||
// Write result to console | ||
console.log(`For a male born on 25 March 1990, their state Pension Date would be ${pensionDateString}`); | ||
``` | ||
|
||
Error Handling | ||
## 2) Server process | ||
After cloning the project from a repository, and running 'npm install', you can run the following to ensure the component is working correctly: | ||
|
||
```script | ||
npm test | ||
``` | ||
|
||
then you can start a simple server by executing... | ||
|
||
```script | ||
npm start | ||
``` | ||
|
||
** the service will start on port 5000 by default. To set a different port configure an environment variable SPA_PORT | ||
|
||
e.g. SPA_PORT=4001 | ||
|
||
Once running, the service will accept requests that supply a date of birth and a | ||
gender, and will return a simple piece of content showing the state pension | ||
date. | ||
|
||
The RESTfull interface provides 2 endpoints: | ||
|
||
##### 1) Get state pension date which provides the state pension age for a given birthday and sex; this is called as per the below query. | ||
|
||
Example query... | ||
|
||
```html | ||
http://localhost/1990-03-10/M | ||
``` | ||
|
||
Would return... | ||
|
||
```json | ||
{ | ||
"statePensionDate": "2058-03-10T00:00:00.000Z" | ||
} | ||
``` | ||
|
||
If the input provided is invalid the rest service will return 400 http status code and, for example, the json | ||
|
||
```json | ||
{ | ||
"error":"The client input was invalid: Date of birth: '1990-03-10', Gender: 'G'" | ||
} | ||
``` | ||
|
||
If an error is thrown while processing the rest service will return 500 http status code and, for example, the json | ||
|
||
|
||
```json | ||
{ | ||
"error":"Unexpected error occurred for input: Date of birth: '1990-03-10', Gender: 'F'" | ||
} | ||
``` | ||
|
||
|
||
##### 2) Ping health which provides a check point for health monitors to call into to ensure the service is up; this is called as per the below query. | ||
|
||
Example query... | ||
|
||
```html | ||
http://localhost/ping | ||
``` | ||
|
||
Would return... | ||
|
||
```html | ||
pong | ||
``` | ||
|
||
|
||
# Caveat | ||
|
||
The dates produced by this package are based on legislation in place at the point of publishing (November 2018). | ||
Dates that fall beyond the current legislation (i.e. after 5/4/1977) are calculated on a best endeavours basis only. | ||
|
||
see below link for fuller details | ||
```html | ||
https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/310231/spa-timetable.pdf | ||
``` | ||
E&OE |
Oops, something went wrong.