Skip to content

Commit

Permalink
Move defineEndpoints to utils package
Browse files Browse the repository at this point in the history
  • Loading branch information
trpfrog committed Oct 18, 2024
1 parent 9ab0b25 commit e94670e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/constants/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineEndpoints } from './defineEndpoints'
import { defineEndpoints } from '@trpfrog.net/utils'

export const services = defineEndpoints({
website: {
Expand Down
4 changes: 3 additions & 1 deletion packages/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@trpfrog.net/config-typescript": "workspace:*"
"@trpfrog.net/config-typescript": "workspace:*",
"@trpfrog.net/config-eslint": "workspace:*",
"@trpfrog.net/utils": "workspace:*"
}
}
3 changes: 3 additions & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"test": "vitest run",
"lint-fix": "eslint . --fix"
},
"dependencies": {
"zod": "^3.23.8"
},
"devDependencies": {
"@trpfrog.net/config-typescript": "workspace:*",
"@trpfrog.net/config-vitest": "workspace:*"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, test, expect, expectTypeOf } from 'vitest'

import { defineEndpoints } from './defineEndpoints'
import { defineEndpoints } from './defineEndpoints.ts'

describe('defineEndpoints', () => {
describe('should correctly parse and return endpoints with all fields provided', () => {
Expand Down Expand Up @@ -154,12 +154,13 @@ describe('defineEndpoints', () => {
).toThrow()
})

test('should throw when production is missing', () => {
test('should throw when production is not a valid URL', () => {
expect(() =>
defineEndpoints({
api: {
port: 3000,
development: 'http://dev.api.local',
production: 'invalid-url',
},
}),
).toThrow()
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { createURL } from './url'
export { composeFunctions, pipeFunctions } from './composeFn'
export { withTimeout } from './timeout'
export { defineEndpoints } from './defineEndpoints'
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e94670e

Please sign in to comment.