-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from GuoXiCheng/dev-c
add storage-lib
- Loading branch information
Showing
14 changed files
with
70 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import axios from 'axios'; | ||
import 'dotenv/config'; | ||
import { TinyRequestInstance } from '../../request-lib'; | ||
import { RequestLib } from '../../enums'; | ||
|
||
export class StartTest { | ||
constructor() { | ||
|
||
} | ||
|
||
getRequest() { | ||
return TinyRequestInstance(RequestLib.axios, axios, process.env.GITEE_TOKEN as string); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { StartTest } from './start-test'; | ||
import { GiteeStorage } from '../../storage-lib/gitee-storage'; | ||
|
||
export class UserStorage extends GiteeStorage { | ||
constructor() { | ||
super(new StartTest().getRequest()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import 'dotenv/config'; | ||
import { TinyRequestInstance } from '../request-lib'; | ||
import { RequestLib } from '..'; | ||
import axios from 'axios'; | ||
import { StartTest } from './helper/start-test'; | ||
|
||
|
||
test('Test TinyRequestInstance', async () => { | ||
const instance = TinyRequestInstance(RequestLib.axios, axios, process.env.GITEE_TOKEN as string); | ||
const detail = await instance.get(process.env.GITEE_GET_ALL_URL as string); | ||
const request = new StartTest().getRequest(); | ||
const detail = await request.get(process.env.GITEE_GET_ALL_URL as string); | ||
expect(detail.length).toBeGreaterThan(0); | ||
}, 30000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { UserStorage } from "./helper/user-storage"; | ||
|
||
test('Test Storage Lib', async () => { | ||
const userStorage = new UserStorage(); | ||
const detail: any[] = await userStorage.findAll(); | ||
expect(detail.length).toBeGreaterThan(0); | ||
}, 30000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export enum StoragePlatform { | ||
gitee = "gitee", | ||
github = "github", | ||
gitlab = "gitlab" | ||
} | ||
|
||
export enum RequestLib { | ||
axios = "axios", | ||
wx = "wx" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
import {TinyRequestInstance} from "./request-lib"; | ||
export enum StoragePlatform { | ||
gitee = "gitee", | ||
github = "github", | ||
gitlab = "gitlab" | ||
} | ||
|
||
export enum RequestLib { | ||
axios = "axios", | ||
wx = "wx" | ||
} | ||
|
||
export type StoragePlatformType = keyof typeof StoragePlatform; | ||
export type RequestLibType = keyof typeof RequestLib; | ||
export {TinyRequestInstance}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { TinyRequest } from "../request-lib/interfaces"; | ||
import { TinyStorage } from "./interfaces"; | ||
|
||
export class GiteeStorage implements TinyStorage { | ||
protected baseUrl = "https://gitee.com"; | ||
constructor(private requestInstance: TinyRequest) { } | ||
|
||
async findOne(): Promise<void> { | ||
this.requestInstance.get(""); | ||
} | ||
|
||
async findAll(): Promise<any> { | ||
const url = `${this.baseUrl}/api/v5/repos/guoxicheng/tiny-crud/issues/I8H4X2/comments`; | ||
return this.requestInstance.get(url); | ||
} | ||
|
||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface TinyStorage { | ||
findOne(): void; | ||
findAll(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { RequestLib, StoragePlatform } from "./enums"; | ||
|
||
export type StoragePlatformType = keyof typeof StoragePlatform; | ||
export type RequestLibType = keyof typeof RequestLib; |