Skip to content

The Calendar JSON API can be used to provide you with a calendar formatted as a 2D array. For that, you may choose to query for the selected month, or the selected year, as explained in the endpoints below.

License

Notifications You must be signed in to change notification settings

Gonzagadavid/calendar-json-api

Repository files navigation

Calendar JSON API {...} 📆

Sumary


Introduction

The Calendar JSON API can be used to provide you with a calendar formatted as a 2D array.

For that, you may choose to query for the selected month, or the selected year, as explained in the endpoints below.


Swagger documentation

Access the swagger documentation:

Production: https://calendar-json-app.adaptable.app/docs

Local: http://localhost:3002/docs


Instructions to start locally

  • clone the repository git clone git@github.com:Gonzagadavid/calendar-json-api.git
  • enter the directory cd calendar-json-api
  • install the dependencies npm install
  • run the command npm run dev
  • the api will be available at http://localhost:3002

Endpoints

Current month /month

Returns the calendar of the current date.

GET https://calendar-json-app.adaptable.app/month

E.G:

Being the current date December 2021, the default response will be:

{
  "December":[
    [  0,  0,  0,  1,  2,  3,  4],
    [  5,  6,  7,  8,  9, 10, 11],
    [ 12, 13, 14, 15, 16, 17, 18],
    [ 19, 20, 21, 22, 23, 24, 25],
    [ 26, 27, 28, 29, 30, 31,  0]
  ],
  "year": 2021
}

I.E:

December 2021

Sunday Monday Tuesday Wednesday Thursday Friday Saturday
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Month name /month/<monthName>

Returns current year`s month calendar.

GET https://calendar-json-app.adaptable.app/month/<monthName>

E.G:

Being 2021 the current year, and November the desired month, the request must be sent as follows:

GET https://calendar-json-app.adaptable.app/month/november

And the response will be:

{
  "November":[
    [  0,  1,  2,  3,  4,  5,  6],
    [  7,  8,  9, 10, 11, 12, 13],
    [ 14, 15, 16, 17, 18, 19, 20],
    [ 21, 22, 23, 24, 25, 26, 27],
    [ 28, 29, 30,  0,  0,  0,  0]
    ],
  "year": 2021
}

I.E:

November 2021

Sunday Monday Tuesday Wednesday Thursday Friday Saturday
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

Month name and year /month/<monthName>?year=<yearValue>

Returns the calendar for the desired month and year.

GET https://calendar-json-app.adaptable.app/month/<monthName>?year=<yearValue>

E.G:

Desired month: October Desired year: 2012

GET https://calendar-json-app.adaptable.app/month/october?year=2012

And the response will be:

{
  "October":[
    [  0,  1,  2,  3,  4,  5,  6],
    [  7,  8,  9, 10, 11, 12, 13],
    [ 14, 15, 16, 17, 18, 19, 20],
    [ 21, 22, 23, 24, 25, 26, 27],
    [ 28, 29, 30, 31,  0,  0,  0]
    ],
  "year": 2012
}

I.E:

October 2012

Sunday Monday Tuesday Wednesday Thursday Friday Saturday
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

Current year /fullyear

Returns the complete calendar for the current year.

GET https://calendar-json-app.adaptable.app/fullyear

E.G:

Being the current year 2021, the response will be:

{
  "year":2021,
  "January":[
    [  0,  0,  0,  0,  0,  1,  2],
    [  3,  4,  5,  6,  7,  8,  9],
    [ 10, 11, 12, 13, 14, 15, 16],
    [ 17, 18, 19, 20, 21, 22, 23],
    [ 24, 25, 26, 27, 28, 29, 30],
    [ 31,  0,  0,  0,  0,  0,  0]
    ],
  "February":[
    [  0,  1,  2,  3,  4,  5,  6],
    [  7,  8,  9, 10, 11, 12, 13],
    [ 14, 15, 16, 17, 18, 19, 20],
    [ 21, 22, 23, 24, 25, 26, 27],
    [ 28,  0,  0,  0,  0,  0,  0]
    ],
  "March":[
    [  0,  1,  2,  3,  4,  5,  6],
    [  7,  8,  9, 10, 11, 12, 13],
    [ 14, 15, 16, 17, 18, 19, 20],
    [ 21, 22, 23, 24, 25, 26, 27],
    [ 28, 29, 30, 31,  0,  0,  0]
    ],
  "April":[
    [  0,  0,  0,  0,  1, 2,  3],
    [  4,  5,  6,  7,  8, 9, 10],
    [11, 12, 13, 14, 15, 16, 17], 
    [18, 19, 20, 21, 22, 23, 24], 
    [25, 26, 27, 28, 29, 30,  0]
    ],
  "May":[
    [  0,  0,  0,  0,  0,  0,  1],
    [  2,  3,  4,  5,  6,  7,  8],
    [  9, 10, 11, 12, 13, 14, 15], 
    [ 16, 17, 18, 19, 20, 21, 22], 
    [ 23, 24, 25, 26, 27, 28, 29], 
    [ 30, 31,  0,  0,  0,  0,  0]
  ],
  "June":[
    [  0,  0,  1,  2,  3,  4,  5],
    [  6,  7,  8,  9, 10, 11, 12], 
    [ 13, 14, 15, 16, 17, 18, 19], 
    [ 20, 21, 22, 23, 24, 25, 26], 
    [ 27, 28, 29, 30,  0,  0,  0]
  ],
  "July":[
    [  0,  0,  0,  0,  1,  2,  3],
    [  4,  5,  6,  7,  8,  9, 10],
    [ 11, 12, 13, 14, 15, 16, 17], 
    [ 18, 19, 20, 21, 22, 23, 24], 
    [ 25, 26, 27, 28, 29, 30, 31]
  ],
  "August":[
    [  1,  2,  3,  4,  5,  6,  7],
    [  8,  9, 10, 11, 12, 13, 14], 
    [ 15, 16, 17, 18, 19, 20, 21], 
    [ 22, 23, 24, 25, 26, 27, 28], 
    [ 29, 30, 31,  0,  0,  0,  0]
  ],
  "September":[
    [  0,  0,  0,  1,  2,  3,  4],
    [  5,  6,  7,  8,  9, 10 ,11],
    [ 12 ,13 ,14 ,15 ,16 ,17 ,18],
    [ 19 ,20 ,21 ,22 ,23 ,24 ,25],
    [ 26 ,27 ,28 ,29 ,30,  0,  0]
  ],
  "October":[
    [  0,  0,  0,  0,  0,  1,  2],
    [  3,  4,  5,  6,  7,  8,  9],
    [ 10, 11, 12, 13, 14, 15, 16], 
    [ 17, 18, 19, 20, 21, 22, 23], 
    [ 24, 25, 26, 27, 28, 29, 30],
    [ 31,  0,  0,  0,  0,  0,  0]
  ],
  "November":[
    [  0,  1,  2,  3,  4,  5,  6],
    [  7,  8,  9, 10, 11, 12, 13],
    [ 14, 15, 16, 17, 18, 19, 20],
    [ 21, 22, 23, 24, 25, 26, 27],
    [ 28, 29, 30,  0,  0,  0,  0]
  ],
  "December":[
    [  0,  0,  0,  1,  2,  3,  4],
    [  5,  6,  7,  8,  9, 10, 11],
    [ 12, 13, 14, 15, 16, 17, 18],
    [ 19, 20, 21, 22, 23, 24, 25],
    [ 26, 27, 28, 29, 30, 31,  0]
  ]
}

Year /fullyear/<year>

Returns the desired year's complete calendar.

GET https://calendar-json-app.adaptable.app/fullyear/<year>

E.G

Entering the year 2031 as a parameter

GET https://calendar-json-app.adaptable.app/fullyear/2031

the response will be:

{
  "year": 2031,
  "January":[
    [  0,  0,  0,  1,  2,  3,  4],
    [  5,  6,  7,  8,  9, 10, 11],
    [ 12, 13, 14, 15, 16, 17, 18],
    [ 19, 20, 21, 22, 23, 24, 25],
    [ 26, 27, 28, 29, 30, 31,  0]
    ],
    "February":[
    [  0,  0,  0,  0,  0,  0,  1],
    [  2,  3,  4,  5,  6,  7,  8],
    [  9, 10, 11, 12, 13, 14, 15],
    [ 16, 17, 18, 19, 20, 21, 22],
    [ 23, 24, 25, 26, 27, 28,  0],
    [  0,  0,  0,  0,  0,  0,  0]
    ],
    "March":[
    [  0,  0,  0,  0,  0,  0,  1],
    [  2,  3,  4,  5,  6,  7,  8],
    [  9, 10, 11, 12, 13, 14, 15],
    [ 16, 17, 18, 19, 20, 21, 22],
    [ 23, 24, 25, 26, 27, 28, 29],
    [ 30, 31,  0,  0,  0,  0,  0]
    ],
    "April":[
    [  0,  0,  1,  2,  3,  4,  5],
    [  6,  7,  8,  9, 10, 11, 12],
    [ 13, 14, 15, 16, 17, 18, 19],
    [ 20, 21, 22, 23, 24, 25, 26],
    [ 27, 28, 29, 30,  0,  0,  0]
    ],
    "May":[
    [  0,  0,  0,  0,  1,  2,  3],
    [  4,  5,  6,  7,  8,  9, 10],
    [ 11, 12, 13, 14, 15, 16, 17],
    [ 18, 19, 20, 21, 22, 23, 24],
    [ 25, 26, 27, 28, 29, 30, 31]
    ],
    "June":[
    [  1,  2,  3,  4,  5,  6,  7],
    [  8,  9, 10, 11, 12, 13, 14],
    [ 15, 16, 17, 18, 19, 20, 21],
    [ 22, 23, 24, 25, 26, 27, 28],
    [ 29, 30,  0,  0,  0,  0,  0]
    ],
    "July":[
    [  0,  0,  1,  2,  3,  4,  5],
    [  6,  7,  8,  9, 10, 11, 12],
    [ 13, 14, 15, 16, 17, 18, 19],
    [ 20, 21, 22, 23, 24, 25, 26],
    [ 27, 28, 29, 30 ,31,  0,  0]
    ],
    "August":[
    [  0,  0,  0,  0,  0,  1,  2],
    [  3,  4,  5,  6,  7,  8,  9],
    [ 10, 11, 12, 13, 14, 15, 16],
    [ 17, 18, 19, 20, 21, 22, 23],
    [ 24, 25, 26, 27, 28, 29, 30],
    [ 31,  0,  0,  0,  0,  0,  0]
    ],
    "September":[
    [  0,  1,  2,  3,  4,  5,  6],
    [  7,  8,  9, 10, 11, 12, 13],
    [ 14, 15, 16, 17, 18, 19, 20],
    [ 21, 22, 23, 24, 25, 26, 27],
    [ 28, 29, 30,  0,  0,  0,  0]
    ],
    "October":[
    [  0,  0,  0,  1,  2,  3,  4],
    [  5,  6,  7,  8,  9, 10, 11],
    [ 12, 13, 14, 15, 16, 17, 18],
    [ 19, 20, 21, 22, 23, 24, 25],
    [ 26, 27, 28, 29, 30, 31,  0]
    ],
    "November":[
    [  0,  0,  0,  0,  0,  0,  1],
    [  2,  3,  4,  5,  6,  7,  8],
    [  9, 10, 11, 12, 13, 14, 15],
    [ 16, 17, 18, 19, 20, 21, 22],
    [ 23, 24, 25, 26, 27, 28, 29],
    [ 30,  0,  0,  0,  0,  0,  0]
    ],
    "December":[
    [  0,  1,  2,  3,  4,  5,  6],
    [  7,  8,  9, 10, 11, 12, 13],
    [ 14, 15, 16, 17, 18, 19, 20],
    [ 21, 22, 23, 24, 25, 26, 27],
    [ 28, 29, 30, 31,  0,  0,  0]
  ]
}

Technologies

  • Typescript
  • Express
  • Jest
  • Ts node dev
  • Super test
  • Dotenv
  • Http status code
  • Eslint
  • Swagger
typescript icon     express icon     jest icon     tsnode icon     eslint icon     eslint icon    

Tests

Developed integration tests, using jest and supertest, for all endpoints

tests results

tests results

tests results


Instructions to start tests locally

  • run the command npm test

Deployment

Deployment on Adaptable

adaptable icon

About

The Calendar JSON API can be used to provide you with a calendar formatted as a 2D array. For that, you may choose to query for the selected month, or the selected year, as explained in the endpoints below.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published