Skip to content

Instantly share code, notes, and snippets.

View dhmlau's full-sized avatar

Diana Lau dhmlau

View GitHub Profile
@dhmlau
dhmlau / gist:28b295c486e4d5f4773b6d1362091b24
Created June 12, 2021 02:21
Snippet of GHQueryController
/**
* Get issues from URL
* @param nextLinkURL
* @param queryService
* @param queryResult
* @returns
*/
async getIssueByURL(nextLinkURL: string, queryService: GhQueryService, queryResult:QueryResult) {
let result = await queryService.getIssuesByURL(nextLinkURL);
export interface GhQueryService {
// this is where you define the Node.js methods that will be
// mapped to REST/SOAP/gRPC operations as stated in the datasource
// json file.
// -------------------------------------------------------
// Add the three methods here.
// Make sure the function names and the parameter names matches
// the ones you defined in the datasource
getIssuesByLabel(repo: string, label: string): Promise<QueryResponse>;
getIssuesByURL(url: string): Promise<QueryResponse>;
@dhmlau
dhmlau / gist:64a81f4d0a5dc9766abced29bdfca6e4
Last active June 12, 2021 00:20
GitHubQueryController
// Uncomment these imports to begin using these cool features!
import {inject} from '@loopback/context';
import {get, param} from '@loopback/openapi-v3';
import {GhQueryService, QueryResponse} from '../services';
// import {inject} from '@loopback/core';
export class GhQueryController {
@dhmlau
dhmlau / gist:438f91f7578424d57f2fc972ebee1987
Last active June 12, 2021 01:27
DataSource with REST Connector - GitHub API
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
import {juggler} from '@loopback/repository';
const config = {
name: 'githubds',
connector: 'rest',
baseURL: 'https://api.github.ibm.com',
crud: false,
options: {
headers: {
@dhmlau
dhmlau / loopback-application.md
Last active May 11, 2022 07:48
Project Application Form - Work in progress
@dhmlau
dhmlau / customer.model.ts
Created March 24, 2020 20:48
LoopBack 4 - default date set in model
import {Entity, model, property} from '@loopback/repository';
import moment from 'moment';
@model()
export class Customer extends Entity {
@property({
type: 'string',
id: true,
generated: true,
})
@dhmlau
dhmlau / customer.controller.ts
Last active March 25, 2020 07:30
LoopBack 4 controller - endpoint with date
import {
Count,
CountSchema,
Filter,
FilterBuilder,
FilterExcludingWhere,
repository,
Where,
WhereBuilder,
} from '@loopback/repository';