Skip to content

bordee/nodejs-api-proxy-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodejs-api-proxy-demo

Api / proxy server demo in node.js


Requirements

Build

npm install

('npm run build' can be used as well)

Usage

Start server (without error logging)

After running the following command, the application should be available on http://locatlost:8080. (Port number can be changed in config/index.js)

npm run start

Start server (with error logging)

Error logging to console is only active in debug mode:

npm run debug

API URIs

/search/1day?city=[search text]

/search/5day?city=[search text]

Normal response

1 day forecast

{
    "forecast": {
        "min": {
            "text": [ForecastText],
            "value": [MinimumValue],
            "unit": [Unit]
        },
        "max": {
            "text": [ForecastText],
            "value": [MaximumValue],
            "unit": [Unit]
        },
        "rain": {
            "text": [RainProbabilityText],
            "value": [RainProbabilityValue]
        }
    }
}

5 days forecast

{
    "forecast": {
        "min": {
            "text": [ForecastText],
            "value": [MinimumValue],
            "unit": [Unit]
        },
        "max": {
            "text": [ForecastText],
            "value": [MaximumValue],
            "unit": [Unit]
        }
    }
}

Error response

{
    error: [ErrorText]
    [, searchString: [SearchString]]
}

(The attribute searchString is returned only when no locations have been found, and no other errors occured.)

For development:

The following command starts the app in debug mode using nodemon, so the server is restarted on code / config changes:

npm run watch

Run tests:

npm run test

About

Api / proxy server demo in node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published