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

feat: add host and port support to TuonoConfig #366

Merged
merged 7 commits into from
Jan 20, 2025

Conversation

Valerioageno
Copy link
Member

@Valerioageno Valerioageno commented Jan 17, 2025

This PR does three things:

  1. Add the server property to tuono.config.ts
  2. Apply the server defaults
  3. Generate the .tuono/config/config.json that will be read by the rust server

In the first commit I added the support for the new object

const config: TuonoConfig = {
   server: {
       host: 'localhost',
       port: 3000
   }
}

I messed up a bit the files because in the same commit I split loadConfig and normalizeConfig in two different files to better manage the test files.

Note

In my opinion utils.ts should be used for silly reusable functions - not core functionalities

The only test that has been added is:

// config/normalize-config.spec.ts
describe('server', () => {
    it('should assign the host and port defined by the user', () => {
      const config: TuonoConfig = {
        server: { host: '0.0.0.0', port: 8080 },
      }

      expect(normalizeConfig(config)).toStrictEqual(
        expect.objectContaining({
          server: expect.objectContaining({
            host: '0.0.0.0',
            port: 8080,
          }) as unknown,
        }),
      )
    })
  })

@github-actions github-actions bot added the typescript Requires typescript knowledge label Jan 17, 2025
@Valerioageno Valerioageno self-assigned this Jan 17, 2025
@marcalexiei marcalexiei linked an issue Jan 18, 2025 that may be closed by this pull request
@Valerioageno Valerioageno marked this pull request as ready for review January 19, 2025 20:18
packages/tuono/src/build/config/load-config.ts Outdated Show resolved Hide resolved
packages/tuono/src/build/index.ts Outdated Show resolved Hide resolved
packages/tuono/src/build/index.ts Outdated Show resolved Hide resolved
packages/tuono/src/build/types.ts Show resolved Hide resolved
packages/tuono/src/build/config/create-json-config.ts Outdated Show resolved Hide resolved
packages/tuono/src/build/config/create-json-config.ts Outdated Show resolved Hide resolved
packages/tuono/src/build/config/create-json-config.ts Outdated Show resolved Hide resolved
packages/tuono/src/build/config/create-json-config.ts Outdated Show resolved Hide resolved
packages/tuono/src/build/config/create-json-config.ts Outdated Show resolved Hide resolved
@marcalexiei marcalexiei merged commit 1a3ccb1 into main Jan 20, 2025
16 checks passed
@marcalexiei marcalexiei deleted the generate-rust-config branch January 20, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Requires typescript knowledge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Setup host config property and create .tuono/config/config.json
2 participants