mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
reg test
This commit is contained in:
committed by
Aiden McClelland
parent
edc37e33f1
commit
dc71a625b2
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
/*.img
|
||||
/buster.zip
|
||||
/product_key
|
||||
config.json
|
||||
@@ -42,7 +42,8 @@ Then open `patch-db`, `ws-example`, and `embassy-os`, in separate tabs.
|
||||
|
||||
`npm i`
|
||||
|
||||
In `ui-config.json`, edit the "mocks" section to look like the following:
|
||||
Copy `config-sample.json` to new file `config.json`
|
||||
In `config.json`, edit the "mocks" section to look like the following:
|
||||
|
||||
```
|
||||
"mocks": {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"rpcPort": "5959",
|
||||
"wsPort": "5960",
|
||||
"maskAs": "tor",
|
||||
"skipStartupAlerts": true
|
||||
"skipStartupAlerts": true,
|
||||
"registryURL": ""
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import { DataModel, PackageDataEntry, PackageMainStatus, PackageState, ServerSta
|
||||
import { RR } from './api-types'
|
||||
import { parsePropertiesPermissive } from 'src/app/util/properties.util'
|
||||
import { Mock } from './mock-app-fixures'
|
||||
import { HttpService } from '../http.service'
|
||||
import { HttpService, Method } from '../http.service'
|
||||
import markdown from 'raw-loader!src/assets/markdown/md-sample.md'
|
||||
import { ConfigService } from '../config.service'
|
||||
|
||||
@Injectable()
|
||||
export class MockApiService extends ApiService {
|
||||
@@ -17,6 +18,7 @@ export class MockApiService extends ApiService {
|
||||
|
||||
constructor (
|
||||
private readonly http: HttpService,
|
||||
private readonly configService: ConfigService,
|
||||
) { super() }
|
||||
|
||||
// every time a patch is returned from the mock, we override its sequence to be 1 more than the last sequence in the patch-db as provided by `o`.
|
||||
@@ -472,26 +474,53 @@ export class MockApiService extends ApiService {
|
||||
// marketplace
|
||||
|
||||
async getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise<RR.GetMarketplaceDataRes> {
|
||||
const registryURL = this.configService.mocks.registryURL
|
||||
if(!registryURL) {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
categories: ['featured', 'bitcoin', 'lightning', 'data', 'messaging', 'social', 'alt coin'],
|
||||
}
|
||||
}
|
||||
const url = `${registryURL}/marketplace/data`
|
||||
let md = await this.http.simpleGet(url)
|
||||
return (md as any)
|
||||
}
|
||||
|
||||
async getEos (params: RR.GetMarketplaceEOSReq): Promise<RR.GetMarketplaceEOSRes> {
|
||||
const registryURL = this.configService.mocks.registryURL
|
||||
if(!registryURL) {
|
||||
await pauseFor(2000)
|
||||
return Mock.MarketplaceEos
|
||||
}
|
||||
const url = `${registryURL}/sys/version/eos`
|
||||
let eos = await this.http.simpleGet(url)
|
||||
return (eos as any)
|
||||
await pauseFor(2000)
|
||||
return Mock.MarketplaceEos
|
||||
}
|
||||
|
||||
async getAvailableList (params: RR.GetAvailableListReq): Promise<RR.GetAvailableListRes> {
|
||||
const registryURL = this.configService.mocks.registryURL
|
||||
if(!registryURL) {
|
||||
await pauseFor(2000)
|
||||
return Mock.AvailableList
|
||||
}
|
||||
const url = `${registryURL}/marketplace/available/list?category=${params.category || 'featured'}&per-page=${params['per-page'] || '20'}&page=${params.page || '1'}&query=${params.query || ''}`
|
||||
let av = await this.http.simpleGet(url)
|
||||
return (av as any)
|
||||
}
|
||||
|
||||
async getAvailableShow (params: RR.GetAvailableShowReq): Promise<RR.GetAvailableShowRes> {
|
||||
const registryURL = this.configService.mocks.registryURL
|
||||
if(!registryURL) {
|
||||
await pauseFor(2000)
|
||||
return Mock.AvailableShow[params.id][params.version || 'latest']
|
||||
}
|
||||
const url = `${registryURL}/marketplace/available?id=${params.id}&version=${params.version || '1.3.0'}`
|
||||
let res = await this.http.simpleGet(url)
|
||||
console.log('res RES RES', res)
|
||||
return (res as any)
|
||||
}
|
||||
|
||||
private nextSequence () {
|
||||
console.log('next')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { InstalledPackageDataEntry, InterfaceDef, Manifest, PackageDataEntry, PackageMainStatus, PackageState } from './patch-db/data-model'
|
||||
|
||||
const { patchDb, api, mocks } = require('../../../ui-config.json') as UiConfig
|
||||
const { patchDb, api, mocks } = require('../../../config.json') as UiConfig
|
||||
|
||||
type UiConfig = {
|
||||
patchDb: {
|
||||
@@ -20,6 +20,7 @@ type UiConfig = {
|
||||
wsPort: number
|
||||
maskAs: 'tor' | 'lan'
|
||||
skipStartupAlerts: boolean
|
||||
registryURL: String
|
||||
}
|
||||
}
|
||||
@Injectable({
|
||||
|
||||
@@ -44,6 +44,11 @@ export class HttpService {
|
||||
if (isRpcSuccess(res)) return res.result
|
||||
}
|
||||
|
||||
async simpleGet (url: string): Promise<object> {
|
||||
const data = await this.http.get(url).toPromise()
|
||||
return data
|
||||
}
|
||||
|
||||
async httpRequest<T> (httpOpts: HttpOptions): Promise<T> {
|
||||
let { body, timeout, ...rest} = this.translateOptions(httpOpts)
|
||||
let req: Observable<{ body: T }>
|
||||
|
||||
Reference in New Issue
Block a user