Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidy up [GitHubGist] routes #8510

Merged
merged 3 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { redirector } from '../../index.js'

export default redirector({
category: 'activity',
route: { base: 'github-gist/last-commit', pattern: ':gistId' },
transformPath: ({ gistId }) => `/github/gist/last-commit/${gistId}`,
dateAdded: new Date('2022-10-09'),
})
16 changes: 16 additions & 0 deletions services/github/gist/github-gist-last-commit-redirect.tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ServiceTester } from '../../tester.js'
export const t = new ServiceTester({
id: 'GithubGistLastCommitRedirect',
title: 'Github Gist Last Commit Redirect',
pathPrefix: '/github-gist',
})

t.create('Last Commit redirect')
.get('/last-commit/a8b8c979d200ffde13cc08505f7a6436', {
followRedirect: false,
})
.expectStatus(301)
.expectHeader(
'Location',
'/github/gist/last-commit/a8b8c979d200ffde13cc08505f7a6436.svg'
)
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import Joi from 'joi'
import { formatDate } from '../text-formatters.js'
import { age as ageColor } from '../color-formatters.js'
import { GithubAuthV3Service } from './github-auth-service.js'
import { documentation, errorMessagesFor } from './github-helpers.js'
import { formatDate } from '../../text-formatters.js'
import { age as ageColor } from '../../color-formatters.js'
import { GithubAuthV3Service } from '../github-auth-service.js'
import { documentation, errorMessagesFor } from '../github-helpers.js'

const schema = Joi.object({
updated_at: Joi.string().required(),
}).required()

export default class GithubGistLastCommit extends GithubAuthV3Service {
static category = 'activity'
static route = { base: 'github-gist/last-commit', pattern: ':gistId' }
static route = { base: 'github/gist/last-commit', pattern: ':gistId' }
static examples = [
{
title: 'GitHub Gist last commit',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServiceTester } from '../tester.js'
import { createServiceTester } from '../../tester.js'
export const t = await createServiceTester()

t.create('last commit in gist (ancient)').get('/871064.json').expectBadge({
Expand Down
8 changes: 8 additions & 0 deletions services/github/gist/github-gist-stars-redirect.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { redirector } from '../../index.js'

export default redirector({
category: 'social',
route: { base: 'github/stars/gists', pattern: ':gistId' },
transformPath: ({ gistId }) => `/github/gist/stars/${gistId}`,
dateAdded: new Date('2022-10-09'),
})
16 changes: 16 additions & 0 deletions services/github/gist/github-gist-stars-redirect.tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ServiceTester } from '../../tester.js'
export const t = new ServiceTester({
id: 'GithubGistStarsRedirect',
title: 'Github Gist Stars Redirect',
pathPrefix: '/github',
})

t.create('Stars redirect')
.get('/stars/gists/a8b8c979d200ffde13cc08505f7a6436', {
followRedirect: false,
})
.expectStatus(301)
.expectHeader(
'Location',
'/github/gist/stars/a8b8c979d200ffde13cc08505f7a6436.svg'
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import gql from 'graphql-tag'
import Joi from 'joi'
import { metric } from '../text-formatters.js'
import { NotFound } from '../index.js'
import { GithubAuthV4Service } from './github-auth-service.js'
import { documentation as commonDocumentation } from './github-helpers.js'
import { metric } from '../../text-formatters.js'
import { NotFound } from '../../index.js'
import { GithubAuthV4Service } from '../github-auth-service.js'
import { documentation as commonDocumentation } from '../github-helpers.js'

const schema = Joi.object({
data: Joi.object({
Expand All @@ -28,7 +28,7 @@ export default class GithubGistStars extends GithubAuthV4Service {
static category = 'social'

static route = {
base: 'github/stars/gists',
base: 'github/gist/stars',
pattern: ':gistId',
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createServiceTester } from '../tester.js'
import { isMetric } from '../test-validators.js'
import { createServiceTester } from '../../tester.js'
import { isMetric } from '../../test-validators.js'

export const t = await createServiceTester()

Expand Down