Skip to content

Commit

Permalink
Add server mock
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Jul 28, 2018
1 parent ba5db0f commit b903e75
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 35 deletions.
15 changes: 11 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@
"author": "Daniel Morgenstern <morgenstern.daniel@gmail.com>",
"scripts": {
"start": "concurrently --kill-others --names \"SERVER,WEB_UI\" -c \"bgBlue.bold,bgMagenta.bold\" \"npm run startServer\" \"npm run startWebui\"",
"dev": "cross-env-shell MOCK=true npm start",
"startWebui": "vue-cli-service serve",
"buildWebui": "vue-cli-service build",
"lintWebui": "vue-cli-service lint",
"startServer": "nodemon server"
},
"dependencies": {
"axios": "^0.18.0",
"vue": "^2.5.16",
"vue-class-component": "^6.0.0",
"vue-material": "^1.0.0-beta-10.2",
"vue-property-decorator": "^7.0.0",
"vue-router": "^3.0.1",
"body-parser": "^1.18.3",
"cors": "^2.8.4",
"cross-env": "^5.2.0",
"express": "^4.16.3",
"morgan": "^1.9.0",
"nodemon": "^1.18.3"
"nodemon": "^1.18.3",
"vue": "^2.5.16",
"vue-class-component": "^6.0.0",
"vue-material": "^1.0.0-beta-10.2",
"vue-property-decorator": "^7.0.0",
"vue-router": "^3.0.1"
},
"devDependencies": {
"@vue/cli-plugin-typescript": "^3.0.0-rc.5",
Expand Down
37 changes: 12 additions & 25 deletions server/artifactory-service.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
const axios = require("axios");
const path = require('path');
const homedir = require('os').homedir();
const config = require(path.join(homedir, '.npmfrog.config.json'));
const path = require("path");
const homedir = require("os").homedir();
const config = require(path.join(homedir, ".npmfrog.config.json"));

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
axios.defaults.baseURL = `${config.artifactory.baseURL}/artifactory/api/npm/`;
axios.defaults.headers.common['Authorization'] = config.artifactory.apiKey;
axios.defaults.headers.common["Authorization"] = config.artifactory.apiKey;

const repoKey = config.artifactory.repoKey;

module.exports = {
fetchPackages: async () => {
const request = axios.get(`${repoKey}/-/all`);
return request;
// return new Promise((resolve, reject) => {
// resolve({data: {
// module1: {
// name: "hello",
// description: "Beschreibung",
// author: "icke eben"
// },
// module2: {
// name: "hello",
// description: "Beschreibung",
// author: "icke eben"
// },
// module3: {
// name: "hello",
// description: "Beschreibung",
// author: "icke eben"
// }
// }});
// });
if (process.env.MOCK) {
return new Promise((resolve, reject) => {
resolve({
data: require('./mock/packages-all.json')
});
});
}
return (request = axios.get(`${repoKey}/-/all`));
}
};
109 changes: 109 additions & 0 deletions server/mock/packages-all.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"_updated": 1532272070591,
"schoenes-module": {
"_id": "schoenes-module",
"_rev": "1-0",
"name": "schoenes-module",
"description": "wunderschoen",
"dist-tags": { "latest": "1.1.0" },
"keywords": ["npm", "test", "quatsch"],
"versions": { "1.1.0": "latest" },
"author": "Erklärbär",
"time": {
"1.0.3": "2018-07-22T14:23:52.861Z",
"1.0.4": "2018-07-22T14:24:57.989Z",
"created": "2018-07-22T14:23:52.861Z",
"modified": "2018-07-22T15:06:48.615Z",
"1.1.0": "2018-07-22T15:06:48.615Z"
},
"users": {},
"license": "ISC"
},
"abgefahrenes-module": {
"_id": "abgefahrenes-module",
"_rev": "1-0",
"name": "abgefahrenes-module",
"description": "Mega abgefahren, alter!",
"dist-tags": { "latest": "1.1.0" },
"versions": { "1.1.0": "latest" },
"author": "Erklärbär",
"time": {
"1.0.3": "2018-07-22T14:23:52.861Z",
"1.0.4": "2018-07-22T14:24:57.989Z",
"created": "2018-07-22T14:23:52.861Z",
"modified": "2018-07-22T15:06:48.615Z",
"1.1.0": "2018-07-22T15:06:48.615Z"
},
"users": {},
"license": "ISC"
},
"tolles-module": {
"_id": "tolles-module",
"_rev": "1-0",
"name": "tolles-module",
"description": "Einfach nur total tolls",
"dist-tags": { "latest": "1.1.0" },
"versions": { "1.1.0": "latest" },
"author": "Erklärbär",
"keywords": ["fractal", "toll", "lustig", "prototype"],
"time": {
"1.0.3": "2018-07-22T14:23:52.861Z",
"1.0.4": "2018-07-22T14:24:57.989Z",
"created": "2018-07-22T14:23:52.861Z",
"modified": "2018-07-22T15:06:48.615Z",
"1.1.0": "2018-07-22T15:06:48.615Z"
},
"users": {},
"license": "ISC"
},
"lustiges-module": {
"_id": "lustiges-module",
"_rev": "1-0",
"name": "lustiges-module",
"description": "superlustig",
"dist-tags": { "latest": "1.1.0" },
"versions": { "1.1.0": "latest" },
"author": "Erklärbär",
"keywords": ["fractal", "toll", "js"],
"time": {
"1.0.3": "2018-07-22T14:23:52.861Z",
"1.0.4": "2018-07-22T14:24:57.989Z",
"created": "2018-07-22T14:23:52.861Z",
"modified": "2018-07-22T15:06:48.615Z",
"1.1.0": "2018-07-22T15:06:48.615Z"
},
"users": {},
"license": "ISC"
},
"@init/fractal-menu-enhancer": {
"_id": "@init/fractal-menu-enhancer",
"_rev": "1-0",
"name": "@init/fractal-menu-enhancer",
"description": "Adds extra functionality to the fractal menu",
"dist-tags": { "latest": "0.3.2" },
"versions": { "0.3.2": "latest" },
"author": {
"name": "Krüger, Steffen (ext)",
"email": "Steffen.Krueger.ext@init.de"
},
"time": {
"0.3.1": "2018-07-22T13:40:13.185Z",
"0.3.2": "2018-07-22T14:21:30.535Z",
"created": "2018-07-22T13:34:54.888Z",
"modified": "2018-07-22T14:21:30.535Z",
"0.3.0": "2018-07-22T13:34:54.888Z"
},
"repository": {
"type": "git",
"url": "https://gitlab.init.de/dmorgenstern/fractal-menu-enhancer"
},
"users": {},
"keywords": ["fractal", "search", "js", "prototype"],
"contributors": [
{
"name": "Morgenstern, Daniel (init)",
"email": "daniel.morgenstern@init.de"
}
]
}
}

0 comments on commit b903e75

Please sign in to comment.