Commit 54dbb153 authored by Vadym Gidulian's avatar Vadym Gidulian

Initial commit

parents
dist/
# Dependency directories
node_modules/
# Logs
logs/
*.log
npm-debug.log*
# Optional npm cache directory
.npm/
# Optional REPL history
.node_repl_history/
stages:
- test
before_script:
- yarn versions
test:
stage: test
script:
- yarn
- yarn run build
tags:
- npm
artifacts:
paths:
- dist/
.*
src
test
gulpfile.js
yarn.lock
# seqid-gen API
An API wrapper for seqid-gen
## Usage
```js
console.log(await Api('http://seqid-gen/items')); // 1
console.log(await Api('http://seqid-gen')); // 2
const api = new Api('http://seqid-gen');
console.log(await api('items')); // 2
console.log(await api()); // 4
```
const gulp = require('gulp');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const paths = new function() {
this.srcDir = 'src';
this.distDir = 'dist';
this.js = this.srcDir + '/index.js';
this.jsOut = this.distDir;
};
// Scripts
gulp.task('js', function () {
return gulp.src(paths.js)
.pipe(babel({
presets: ['env']
}))
.pipe(uglify({
compress: true,
mangle: {
toplevel: true
}
}))
.pipe(gulp.dest(paths.jsOut));
});
// Stages
gulp.task('watch', function () {
gulp.watch(paths.js, gulp.task('js'));
});
gulp.task('build', gulp.task('js'));
gulp.task('default', gulp.task('build'));
{
"name": "@gviagroup/seqid-gen-api",
"version": "1.0.0",
"description": "An API wrapper for seqid-gen",
"main": "dist/index.js",
"scripts": {
"start": "gulp && gulp watch",
"build": "gulp"
},
"dependencies": {
"axios": "^0.18.0"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"gulp": "^4.0.0",
"gulp-babel": "^7.0.1",
"gulp-uglify": "^3.0.1"
}
}
'use strict';
const axios = require('axios');
module.exports = Api;
function Api(url) {
if (this instanceof Api) {
if (url[url.length - 1] !== '/') url += '/';
return function (namespace) {
return Api(url + (namespace || ''));
};
} else {
return axios.get(url).then(({data}) => +data);
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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