Commit 7c6e4cd7 authored by Carsten Bleek's avatar Carsten Bleek
Browse files

Initial commit

parents
Pipeline #1565 failed with stages
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
3.3.4
\ No newline at end of file
# OpenAPI generated server
## Overview
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
### Running the server
To run the server, run:
```
npm start
```
To view the Swagger UI interface:
```
open http://localhost:8080/docs
```
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.
openapi: 3.0.0
info:
description: API for an archive of job postings.
title: Job Archive
version: 1.0.0
servers:
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/SJhumili/JobArchiveAPI/1.0.0
- description: Test in localserver
url: http://localhost:8000
- description: Test in api.yawik.org
url: https://api.yawik.org
security:
- bearerAuth: []
tags:
- description: Operations about auth
name: auth
- description: Operations about user
name: user
- description: Operations about job
name: job
paths:
/signup:
post:
description: User be able to sign up with username, password, email. After sign up backend will send token to email.
operationId: signupuser
requestBody:
content:
application/json:
example:
username: test
email: test@test.com
password: test
schema:
$ref: '#/components/schemas/User'
description: Created user object
required: true
responses:
200:
description: New user successfully created.
default:
description: The eamil is using by someone else.
security: []
summary: Create user
tags:
- auth
x-swagger-router-controller: Auth
/signin:
post:
description: User be able to sign into the system and server will respond access-token, and this access-token should be stored in session. This access-token will be used to use other api. Backend will identify user using access-token.
operationId: signin
requestBody:
content:
application/json:
example:
email: test@test.com
password: test
schema:
$ref: '#/components/schemas/SigninRequest'
description: Created user object
required: true
responses:
200:
content:
application/xml:
schema:
example: Bearer 35775k6dehgn678865k87k748o233
type: string
application/json:
schema:
example: Bearer 35775k6dehgn678865k87k748o233
type: string
description: successful operation
headers:
X-Rate-Limit:
description: calls per hour allowed by the user
explode: false
schema:
format: int32
type: integer
style: simple
X-Expires-After:
description: date in UTC when token expires
explode: false
schema:
format: date-time
type: string
style: simple
400:
description: Invalid email/password supplied
404:
description: User not found
422:
description: email/password not supplied
security: []
summary: Sign in with email and password
tags:
- auth
x-swagger-router-controller: Auth
/logout:
post:
operationId: logoutUser
responses:
200:
description: User successfully log out.
default:
description: Access token is missing or invalid
summary: Logs out current logged in user
tags:
- auth
x-swagger-router-controller: Auth
/validateemail:
get:
operationId: confirmemail
parameters:
- description: this token is from backend after sign up
example: awevbbrntye2y53n5467xcvbn35u7mu3456
explode: true
in: query
name: token
required: true
schema:
type: string
style: form
responses:
200:
description: Email address has been confirmed.
default:
description: Something went wrong
security: []
summary: Confirm user's email address
tags:
- auth
x-swagger-router-controller: Auth
/api/user:
delete:
description: User be able to delete profile.
operationId: deleteUser
responses:
200:
description: Your profile deleted successfully.
401:
description: Access token is missing or invalid
summary: Delete user
tags:
- user
x-swagger-router-controller: User
get:
description: An authenticated user be able to retrieve his or her information
operationId: getuser
responses:
200:
content:
application/json:
example:
username: test
email: test@test.com
password: test
schema:
$ref: '#/components/schemas/User'
application/xml:
example:
username: test
email: test@test.com
password: test
schema:
$ref: '#/components/schemas/User'
description: successful operation
401:
description: Access token is missing or invalid
summary: Get user information
tags:
- user
x-swagger-router-controller: User
put:
description: An authenticated user be able to update information.
operationId: updateuser
requestBody:
content:
application/json:
example:
username: test
email: test@test.com
password: test
schema:
$ref: '#/components/schemas/User'
description: Updated user object
required: true
responses:
200:
description: User data successfully updated.
default:
description: Access token is missing or invalid
summary: Update user profile
tags:
- user
x-swagger-router-controller: User
/api/addjoblink:
post:
description: An authenticated user be able to post a link
operationId: addjoblink
requestBody:
content:
application/json:
example:
url: http://example/job1
schema:
type: string
description: Job url
required: true
responses:
200:
description: Job link added successfully.
401:
description: Access token is missing or invalid
summary: Post a link
tags:
- job
x-swagger-router-controller: Job
/api/listlinks:
get:
description: An authenticated user be able to retrieve joblinks
operationId: getjoblinks
parameters:
- description: if type='all' user be able to retrieve all jobads but not 'all' user will retrieve his own posted jobads
explode: true
in: query
name: type
required: false
schema:
enum:
- all
- mine
example: all
type: string
style: form
responses:
200:
content:
application/json:
example:
joblinks:
- http://example/job1
- http://example/job2
schema:
items:
type: string
type: array
description: Job links
401:
description: Access token is missing or invalid
summary: Get Job lists
tags:
- job
x-swagger-router-controller: Job
components:
responses:
UnauthorizedError:
description: Access token is missing or invalid
schemas:
User:
example:
password: password
email: email
username: username
properties:
username:
type: string
email:
type: string
password:
type: string
type: object
xml:
name: User
SigninRequest:
example:
password: password
email: email
properties:
email:
type: string
password:
type: string
type: object
securitySchemes:
bearerAuth:
bearerFormat: JWT
scheme: bearer
type: http
'use strict';
var utils = require('../utils/writer.js');
var Auth = require('../service/AuthService');
module.exports.confirmemail = function confirmemail (req, res, next) {
var token = req.swagger.params['token'].value;
Auth.confirmemail(token)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.logoutUser = function logoutUser (req, res, next) {
Auth.logoutUser()
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.signin = function signin (req, res, next) {
var signinRequest = req.swagger.params['SigninRequest'].value;
Auth.signin(signinRequest)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.signupuser = function signupuser (req, res, next) {
var user = req.swagger.params['User'].value;
Auth.signupuser(user)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
'use strict';
var utils = require('../utils/writer.js');
var Job = require('../service/JobService');
module.exports.addjoblink = function addjoblink (req, res, next) {
var body = req.swagger.params['body'].value;
Job.addjoblink(body)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.getjoblinks = function getjoblinks (req, res, next) {
var type = req.swagger.params['type'].value;
Job.getjoblinks(type)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
'use strict';
var utils = require('../utils/writer.js');
var User = require('../service/UserService');
module.exports.deleteUser = function deleteUser (req, res, next) {
User.deleteUser()
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.getuser = function getuser (req, res, next) {
User.getuser()
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.updateuser = function updateuser (req, res, next) {
var user = req.swagger.params['User'].value;
User.updateuser(user)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
'use strict';
var fs = require('fs'),
path = require('path'),
http = require('http');
var app = require('connect')();
var swaggerTools = require('swagger-tools');
var jsyaml = require('js-yaml');
var serverPort = 8080;
// swaggerRouter configuration
var options = {
swaggerUi: path.join(__dirname, '/openapi.json'),
controllers: path.join(__dirname, './controllers'),
useStubs: process.env.NODE_ENV === 'development' // Conditionally turn on stubs (mock mode)
};
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
var spec = fs.readFileSync(path.join(__dirname,'api/openapi.yaml'), 'utf8');
var swaggerDoc = jsyaml.safeLoad(spec);
// Initialize the Swagger middleware
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
// Interpret Swagger resources and attach metadata to request - must be first in swagger-tools middleware chain
app.use(middleware.swaggerMetadata());
// Validate Swagger requests
app.use(middleware.swaggerValidator());
// Route validated requests to appropriate controller
app.use(middleware.swaggerRouter(options));
// Serve the Swagger documents and Swagger UI
app.use(middleware.swaggerUi());
// Start the server
http.createServer(app).listen(serverPort, function () {
console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort);
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort);
});
});
../esprima/bin/esparse.js
\ No newline at end of file
../esprima/bin/esvalidate.js
\ No newline at end of file
../js-yaml/bin/js-yaml.js
\ No newline at end of file
../json-refs/bin/json-refs
\ No newline at end of file
../mime/cli.js
\ No newline at end of file
../mkdirp/bin/cmd.js
\ No newline at end of file
../swagger-tools/bin/swagger-tools
\ No newline at end of file
../z-schema/bin/z-schema
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2015 Linus Unnebäck
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# `append-field`
A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant
field appender (for lack of a better name). Useful for people implementing
`application/x-www-form-urlencoded` and `multipart/form-data` parsers.
It works best on objects created with `Object.create(null)`. Otherwise it might
conflict with variables from the prototype (e.g. `hasOwnProperty`).
## Installation
```sh
npm install --save append-field
```
## Usage
```javascript
var appendField = require('append-field')
var obj = Object.create(null)
appendField(obj, 'pets[0][species]', 'Dahut')
appendField(obj, 'pets[0][name]', 'Hypatia')
appendField(obj, 'pets[1][species]', 'Felis Stultus')
appendField(obj, 'pets[1][name]', 'Billie')
console.log(obj)
```
```text
{ pets:
[ { species: 'Dahut', name: 'Hypatia' },
{ species: 'Felis Stultus', name: 'Billie' } ] }
```
## API
### `appendField(store, key, value)`
Adds the field named `key` with the value `value` to the object `store`.
## License
MIT
var parsePath = require('./lib/parse-path')
var setValue = require('./lib/set-value')
function appendField (store, key, value) {
var steps = parsePath(key)
steps.reduce(function (context, step) {
return setValue(context, step, context[step.key], value)
}, store)
}
module.exports = appendField
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment