New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rastapi

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rastapi - npm Package Compare versions

Comparing version
0.0.5
to
0.0.6
+1
-1
package.json
{
"name": "rastapi",
"version": "0.0.5",
"version": "0.0.6",
"description": "Fast and easy-to-use API maker made for JavaScript",

@@ -5,0 +5,0 @@ "main": "rastapi.js",

@@ -112,9 +112,19 @@ // noinspection JSUnusedGlobalSymbols

class RastResponse {
constructor(request, response) {
constructor(request, response, query, vars) {
this._request = request;
this._response = response;
this._ended = false;
this._vars = vars;
this._query = query;
this.url = request.url;
}
getVariables() {
return this._vars;
}
getQuery() {
return this._query;
}
end(string, contentType = "text/json") {

@@ -199,6 +209,17 @@ if (this._ended) return false;

let vars = {};
const dataUrl = urls.find(i => i === req.url) || urls.find(a => {
const __n = req.url.split("/")[req.url.split("/").length - 1];
const _n = __n ? __n.split("?")[0] : null;
const url = [...req.url.split("/").reverse().slice(1).reverse(), ...(_n ? [_n] : [])].join("/");
const _q = req.url.split("/")[req.url.split("/").length - 1].split("?").slice(1).join("?");
const query = {};
if (_q) {
_q.split("&").forEach(i => {
const _i = i.split("=");
if (_i[0] && _i[1]) query[_i[0]] = _i.slice(1).join("=");
});
}
const dataUrl = urls.find(i => i === url) || urls.find(a => {
vars = {};
const A = a.split("/").slice(1);
const B = req.url.split("/").slice(1);
const B = url.split("/").slice(1);
if (A.length !== B.length) return false;

@@ -220,3 +241,3 @@ let all = false;

if (req.method === "GET") {
const response = new RastResponse(req, res, vars);
const response = new RastResponse(req, res, query, vars);
if (this._readers.get(Method.GET).has(dataUrl)) {

@@ -283,3 +304,3 @@ const res = this._readers.get(Method.GET).get(dataUrl);

/**
* @param {function} cb
* @param {function(RastResponse)} cb
* @param {string?} method

@@ -286,0 +307,0 @@ * @param {string?} url

@@ -65,7 +65,16 @@ # RastAPI

$rast.get("/test/:test");
server.json((res, vars) => {
return {"message": "You are in /test/" + vars.test};
server.json(res => {
return {"message": "You are in /test/" + res.getVariables().test};
});
```
### Using url query
```javascript
$rast.get("/test");
server.json(res => {
return {"message": "You have successfully entered!", "query": res.getQuery()};
});
```
### Not found page

@@ -72,0 +81,0 @@