Commit 2ff4cec6 authored by Ole Christian Eidheim's avatar Ole Christian Eidheim Committed by eidheim
Browse files

Initial commit

parents
{
"presets": ["@babel/preset-env", "@babel/preset-flow"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}
node_modules
image: node:latest
stages:
- build # Jobs placed in build-stage will run first
- test # Jobs placed in tets-stage will run after build-jobs
- deploy # Jobs placed in build-stage will run last after test-jobs
install:
stage: build
script:
- npm install
# Keep node_modules-folder for the following stages:
artifacts:
paths:
- node_modules
test:
stage: test # Job test will run in parallel with the job flow
script:
- npm test
flow:
stage: test # Job flow will run in parallel with the job test
script:
- npm install --global flow-bin
- flow check
deploy:
stage: deploy
script:
- mkdir ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- touch ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa # Required permission by ssh
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- apt-get update
- apt-get install --assume-yes rsync
- rsync --archive --delete --exclude='.git' --exclude='node_modules' . app@app.ntnu.no:app
- ssh app@app.ntnu.no systemctl --user restart app
only:
- master
package-lock=false
{
"printWidth": 120,
"singleQuote": true
}
// flow-typed signature: fe7f00984c44d69833f19bc39895832f
// flow-typed version: a4cc3d5e98/axios_v0.19.x/flow_>=v0.104.x
declare module 'axios' {
import type { Agent as HttpAgent } from 'http';
import type { Agent as HttpsAgent } from 'https';
declare type AxiosTransformer<T> = (
data: T,
headers?: { [key: string]: mixed, ...},
) => mixed;
declare type ProxyConfig = {|
host: string,
port: number,
auth?: {|
username: string,
password: string,
|},
protocol?: string,
|};
declare class Cancel {
constructor(message?: string): Cancel;
message: string;
}
declare type Canceler = (message?: string) => void;
declare type CancelTokenSource = {|
token: CancelToken,
cancel: Canceler,
|};
declare class CancelToken {
constructor(executor: (cancel: Canceler) => void): void;
static source(): CancelTokenSource;
promise: Promise<Cancel>;
reason?: Cancel;
throwIfRequested(): void;
}
declare type Method =
| 'get'
| 'GET'
| 'delete'
| 'DELETE'
| 'head'
| 'HEAD'
| 'options'
| 'OPTIONS'
| 'post'
| 'POST'
| 'put'
| 'PUT'
| 'patch'
| 'PATCH';
declare type ResponseType =
| 'arraybuffer'
| 'blob'
| 'document'
| 'json'
| 'text'
| 'stream';
declare type AxiosAdapter = (
config: AxiosXHRConfig<mixed>
) => Promise<AxiosXHR<mixed>>;
declare type AxiosXHRConfigBase<T, R = T> = {
adapter?: AxiosAdapter,
auth?: {|
username: string,
password: string,
|},
baseURL?: string,
cancelToken?: CancelToken,
headers?: { [key: string]: mixed, ...},
httpAgent?: HttpAgent,
httpsAgent?: HttpsAgent,
maxContentLength?: number,
maxRedirects?: number,
socketPath?: string | null,
params?: { [key: string]: mixed, ...},
paramsSerializer?: (params: { [key: string]: mixed, ...}) => string,
onUploadProgress?: (progressEvent: ProgressEvent) => void,
onDownloadProgress?: (progressEvent: ProgressEvent) => void,
proxy?: ProxyConfig | false,
responseType?: ResponseType,
timeout?: number,
transformRequest?: AxiosTransformer<T> | Array<AxiosTransformer<T>>,
transformResponse?: AxiosTransformer<R> | Array<AxiosTransformer<R>>,
validateStatus?: (status: number) => boolean,
withCredentials?: boolean,
xsrfCookieName?: string,
xsrfHeaderName?: string,
...
};
declare type AxiosXHRConfig<T, R = T> = {
...$Exact<AxiosXHRConfigBase<T, R>>,
data?: T,
method?: Method,
url: string,
...
};
declare type AxiosXHRConfigShape<T, R = T> = $Shape<AxiosXHRConfig<T, R>>;
declare type AxiosXHR<T, R = T> = {|
config: AxiosXHRConfig<T, R>,
data: R,
headers: ?{[key: string]: mixed, ...},
status: number,
statusText: string,
request: http$ClientRequest<> | XMLHttpRequest | mixed,
|};
declare type AxiosInterceptorIdent = number;
declare type AxiosRequestInterceptor<T, R = T> = {|
use(
onFulfilled: ?(
response: AxiosXHRConfig<T, R>
) => Promise<AxiosXHRConfig<mixed>> | AxiosXHRConfig<mixed>,
onRejected: ?(error: mixed) => mixed
): AxiosInterceptorIdent,
eject(ident: AxiosInterceptorIdent): void,
|};
declare type AxiosResponseInterceptor<T, R = T> = {|
use(
onFulfilled: ?(response: AxiosXHR<T, R>) => mixed,
onRejected: ?(error: mixed) => mixed
): AxiosInterceptorIdent,
eject(ident: AxiosInterceptorIdent): void,
|};
declare type AxiosPromise<T, R = T> = Promise<AxiosXHR<T, R>>;
declare class Axios {
<T, R>(
config: AxiosXHRConfig<T, R> | string,
config?: AxiosXHRConfigShape<T, R>
): AxiosPromise<T, R>;
constructor<T, R>(config?: AxiosXHRConfigBase<T, R>): void;
request<T, R>(
config: AxiosXHRConfig<T, R> | string,
config?: AxiosXHRConfigShape<T, R>
): AxiosPromise<T, R>;
delete<R>(
url: string,
config?: AxiosXHRConfigBase<mixed, R>
): AxiosPromise<mixed, R>;
get<R>(
url: string,
config?: AxiosXHRConfigBase<mixed, R>
): AxiosPromise<mixed, R>;
head<R>(
url: string,
config?: AxiosXHRConfigBase<mixed, R>
): AxiosPromise<mixed, R>;
options<R>(
url: string,
config?: AxiosXHRConfigBase<mixed, R>
): AxiosPromise<mixed, R>;
post<T, R>(
url: string,
data?: T,
config?: AxiosXHRConfigBase<T, R>
): AxiosPromise<T, R>;
put<T, R>(
url: string,
data?: T,
config?: AxiosXHRConfigBase<T, R>
): AxiosPromise<T, R>;
patch<T, R>(
url: string,
data?: T,
config?: AxiosXHRConfigBase<T, R>
): AxiosPromise<T, R>;
interceptors: {|
request: AxiosRequestInterceptor<mixed>,
response: AxiosResponseInterceptor<mixed>,
|};
defaults: {|
...$Exact<AxiosXHRConfigBase<mixed>>,
headers: { [key: string]: mixed, ...},
|};
getUri<T, R>(config?: AxiosXHRConfig<T, R>): string;
}
declare class AxiosError<T, R = T> extends Error {
config: AxiosXHRConfig<T, R>;
request?: http$ClientRequest<> | XMLHttpRequest;
response?: AxiosXHR<T, R>;
code?: string;
isAxiosError: boolean;
}
declare interface AxiosExport extends Axios {
<T, R>(
config: AxiosXHRConfig<T, R> | string,
config?: AxiosXHRConfigShape<T, R>
): AxiosPromise<T, R>;
Axios: typeof Axios;
Cancel: typeof Cancel;
CancelToken: typeof CancelToken;
isCancel(value: mixed): boolean;
create(config?: AxiosXHRConfigBase<T, R>): Axios;
all: typeof Promise.all;
spread<T, R>(callback: (...args: T) => R): (array: T) => R;
}
declare type $AxiosXHRConfigBase<T, R = T> = AxiosXHRConfigBase<T, R>;
declare type $AxiosXHRConfig<T, R = T> = AxiosXHRConfig<T, R>;
declare type $AxiosXHR<T, R = T> = AxiosXHR<T, R>;
declare type $AxiosError<T, R = T> = AxiosError<T, R>;
declare module.exports: AxiosExport;
}
// flow-typed signature: 7e46c8fddb9d601f9b5b405919c74216
// flow-typed version: 72a1136f77/express_v4.17.x/flow_>=v0.104.x
declare type express$RouterOptions = {
caseSensitive?: boolean,
mergeParams?: boolean,
strict?: boolean,
...
};
declare class express$RequestResponseBase {
app: express$Application<any, any>;
get(field: string): string | void;
}
declare type express$RequestParams = { [param: string]: string, ... };
/*
NOTE: Use caution when extending `express$Request` or `express$Response`. When
a request first hits the server, its `req` and `res` will not have any
additional properties, even if you explicitly type them with your custom
subclass. Subsequent middleware may assign these properties, but you must be
cognizant of this ordering. One way to handle this is marking all properties
as optional to force refinement every time a property is accessed. Therefore,
we advise that you always mark properties as _optional_ in `express$Request`
and `express$Response` subclasses.
You may decide not to do this, in which case the typings will be unsound and
the behavior will be similar to how arrays work in Flow. See here for more
information: https://flow.org/en/docs/types/arrays/#toc-array-access-is-unsafe
See #3578 and #3337 for additional discussion. If you have ideas on how to
improve these typings, please share them in #3578 or open a new issue.
**BAD**
declare class test_express$CustomRequest extends express$Request {
foo: string;
}
**GOOD**
declare class test_express$CustomRequest extends express$Request {
foo: string | void;
}
*/
declare class express$Request extends http$IncomingMessage mixins express$RequestResponseBase {
baseUrl: string;
body: mixed;
cookies: { [cookie: string]: string, ... };
connection: net$Socket;
fresh: boolean;
hostname: string;
ip: string;
ips: Array<string>;
method: string;
originalUrl: string;
params: express$RequestParams;
path: string;
protocol: "https" | "http";
query: { [name: string]: string | Array<string>, ... };
route: string;
secure: boolean;
signedCookies: { [signedCookie: string]: string, ... };
stale: boolean;
subdomains: Array<string>;
xhr: boolean;
accepts(types: string): string | false;
accepts(types: Array<string>): string | false;
acceptsCharsets(...charsets: Array<string>): string | false;
acceptsEncodings(...encoding: Array<string>): string | false;
acceptsLanguages(...lang: Array<string>): string | false;
header(field: string): string | void;
is(type: string): string | false;
param(name: string, defaultValue?: string): string | void;
}
declare type express$CookieOptions = {
domain?: string,
encode?: (value: string) => string,
expires?: Date,
httpOnly?: boolean,
maxAge?: number,
path?: string,
secure?: boolean,
signed?: boolean,
...
};
declare type express$Path = string | RegExp;
declare type express$RenderCallback = (
err: Error | null,
html?: string
) => mixed;
declare type express$SendFileOptions = {
maxAge?: number,
root?: string,
lastModified?: boolean,
headers?: { [name: string]: string, ... },
dotfiles?: "allow" | "deny" | "ignore",
...
};
declare class express$Response extends http$ServerResponse mixins express$RequestResponseBase {
headersSent: boolean;
locals: { [name: string]: mixed, ... };
append(field: string, value?: string): this;
attachment(filename?: string): this;
cookie(name: string, value: string, options?: express$CookieOptions): this;
clearCookie(name: string, options?: express$CookieOptions): this;
download(
path: string,
filename?: string,
callback?: (err?: ?Error) => void
): this;
format(typesObject: { [type: string]: Function, ... }): this;
json(body?: mixed): this;
jsonp(body?: mixed): this;
links(links: { [name: string]: string, ... }): this;
location(path: string): this;
redirect(url: string, ...args: Array<void>): this;
redirect(status: number, url: string, ...args: Array<void>): this;
render(
view: string,
locals?: { [name: string]: mixed, ... },
callback?: express$RenderCallback
): this;
send(body?: mixed): this;
sendFile(
path: string,
options?: express$SendFileOptions,
callback?: (err?: ?Error) => mixed
): this;
sendStatus(statusCode: number): this;
header(field: string, value?: string): this;
header(headers: { [name: string]: string, ... }): this;
set(field: string, value?: string | string[]): this;
set(headers: { [name: string]: string, ... }): this;
status(statusCode: number): this;
type(type: string): this;
vary(field: string): this;
req: express$Request;
}
declare type express$NextFunction = (err?: ?Error | "route") => mixed;
declare type express$Middleware<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> =
((req: Req, res: Res, next: express$NextFunction) => mixed) |
((error: Error, req: Req, res: Res, next: express$NextFunction) => mixed);
declare interface express$RouteMethodType<
T,
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> {
(middleware: express$Middleware<Req, Res>): T;
(...middleware: Array<express$Middleware<Req, Res>>): T;
(
path: express$Path | $ReadOnlyArray<express$Path>,
...middleware: Array<express$Middleware<Req, Res>>
): T;
}
declare class express$Route<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> {
all: express$RouteMethodType<this, Req, Res>;
get: express$RouteMethodType<this, Req, Res>;
post: express$RouteMethodType<this, Req, Res>;
put: express$RouteMethodType<this, Req, Res>;
head: express$RouteMethodType<this, Req, Res>;
delete: express$RouteMethodType<this, Req, Res>;
options: express$RouteMethodType<this, Req, Res>;
trace: express$RouteMethodType<this, Req, Res>;
copy: express$RouteMethodType<this, Req, Res>;
lock: express$RouteMethodType<this, Req, Res>;
mkcol: express$RouteMethodType<this, Req, Res>;
move: express$RouteMethodType<this, Req, Res>;
purge: express$RouteMethodType<this, Req, Res>;
propfind: express$RouteMethodType<this, Req, Res>;
proppatch: express$RouteMethodType<this, Req, Res>;
unlock: express$RouteMethodType<this, Req, Res>;
report: express$RouteMethodType<this, Req, Res>;
mkactivity: express$RouteMethodType<this, Req, Res>;
checkout: express$RouteMethodType<this, Req, Res>;
merge: express$RouteMethodType<this, Req, Res>;
// @TODO Missing 'm-search' but get flow illegal name error.
notify: express$RouteMethodType<this, Req, Res>;
subscribe: express$RouteMethodType<this, Req, Res>;
unsubscribe: express$RouteMethodType<this, Req, Res>;
patch: express$RouteMethodType<this, Req, Res>;
search: express$RouteMethodType<this, Req, Res>;
connect: express$RouteMethodType<this, Req, Res>;
}
declare type express$RouterUseable<Req: express$Request, Res: express$Response> =
| express$Middleware<Req, Res>
| express$Router<Req, Res>
| $ReadOnlyArray<express$Middleware<Req, Res> | express$Router<Req, Res>>;
declare class express$Router<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> extends express$Route<Req, Res> {
constructor(options?: express$RouterOptions): void;
route(path: string): express$Route<Req, Res>;
static <Req2: express$Request, Res2: express$Response>(
options?: express$RouterOptions,
): express$Router<Req2, Res2>;
use(express$RouterUseable<Req, Res>, ...express$RouterUseable<Req, Res>[]): this;
use(express$Path, express$RouterUseable<Req, Res>, ...express$RouterUseable<Req, Res>[]): this;
handle(
req: http$IncomingMessage<>,
res: http$ServerResponse,
next: express$NextFunction
): void;
param(
param: string,
callback: (
req: Req,
res: Res,
next: express$NextFunction,
value: string,
paramName: string,
) => mixed
): void;
(
req: http$IncomingMessage<>,
res: http$ServerResponse,
next?: ?express$NextFunction
): void;
}
/*
With flow-bin ^0.59, express app.listen() is deemed to return any and fails flow type coverage.
Which is ironic because https://github.com/facebook/flow/blob/master/Changelog.md#misc-2 (release notes for 0.59)
says "Improves typings for Node.js HTTP server listen() function." See that? IMPROVES!
To work around this issue, we changed Server to ?Server here, so that our invocations of express.listen() will
not be deemed to lack type coverage.
*/
declare class express$Application<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> extends express$Router<Req, Res> mixins events$EventEmitter {
constructor(): void;
locals: { [name: string]: mixed, ... };
mountpath: string;
listen(
port: number,
hostname?: string,
backlog?: number,
callback?: (err?: ?Error) => mixed
): ?http$Server;
listen(
port: number,
hostname?: string,
callback?: (err?: ?Error) => mixed
): ?http$Server;
listen(port: number, callback?: (err?: ?Error) => mixed): ?http$Server;
listen(path: string, callback?: (err?: ?Error) => mixed): ?http$Server;
listen(handle: Object, callback?: (err?: ?Error) => mixed): ?http$Server;
disable(name: string): void;
disabled(name: string): boolean;
enable(name: string): this;
enabled(name: string): boolean;
engine(name: string, callback: Function): void;
/**
* Mixed will not be taken as a value option. Issue around using the GET http method name and the get for settings.
*/
// get(name: string): mixed;
set(name: string, value: mixed): mixed;
render(
name: string,
optionsOrFunction: { [name: string]: mixed, ... },
callback: express$RenderCallback
): void;
handle(
req: http$IncomingMessage<>,
res: http$ServerResponse,
next?: ?express$NextFunction
): void;
// callable signature is not inherited
(
req: http$IncomingMessage<>,
res: http$ServerResponse,
next?: ?express$NextFunction
): void;
}
declare type JsonOptions = {
inflate?: boolean,
limit?: string | number,
reviver?: (key: string, value: mixed) => mixed,
strict?: boolean,
type?: string | Array<string> | ((req: express$Request) => boolean),
verify?: (
req: express$Request,
res: express$Response,
buf: Buffer,
encoding: string
) => mixed,
...
};