Skip to content

Commit

Permalink
Added shortened url to returned data
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacxk committed Apr 26, 2020
1 parent cf875fa commit 26dc690
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,35 @@ const { version } = require('../package.json');
const linguist = require('@sourcebin/linguist/dist/linguist.json');

const [
url_long, ...urls
url_long,
url_short,
...urls
] = [
'https://sourceb.in', 'sourceb.in', 'srcb.in'
'https://sourceb.in',
'https://srcb.in',
'sourceb.in',
'srcb.in'
];

export class Bin {
public key: string;
public files: Array<BinFile>;
public created: Date;
public url: string;
public shortened: string;

constructor(options: BinOptions) {
this.key = options.key;
this.url = `${ url_long }/${ this.key }`;
this.shortened = `${ url_short }/${ this.key }`;
this.created = options.created;
this.files = options.files;
}
}

export class BinFile {
public languageId: number;
public language?: Language;
public language: Language;
public content: string;

constructor(options: BinFileOptions) {
Expand Down Expand Up @@ -81,7 +88,8 @@ export async function get(k: string): Promise<Bin> {
'User-Agent': 'SourceBin Wrapper/' + version
},
method: 'get'
}).then(checkStatus)
})
.then(checkStatus)
.then(res => res.json());

const binFiles: Array<BinFile> = [];
Expand Down

0 comments on commit 26dc690

Please sign in to comment.