The Best Themes for programmers
🎨🚀 A never seen collection of 165 hand crafted themes no where to be found on Internet 💻
🎨🚀 A never seen collection of 165 hand crafted themes no where to be found on Internet 💻
Full workbench mockup using this variant's colors and tokenColors.
Loading...
Workbench UI color keys from the theme JSON colors map.
TextMate scopes and font styles (syntax highlighting rules).
| scope | foreground | fontStyle |
|---|---|---|
| comment, punctuation.definition.comment | #B362FF | — |
| entity | #FAD000 | — |
| constant | #FF628C | — |
| keyword, storage.type.class.js | #FF9D00 | — |
| meta | #9EFFFF | — |
| invalid | #EC3A37F5 | — |
| meta.brace, punctuation.definition.parameters.begin.js, punctuation.definition.parameters.end.js | #E1EFFF | — |
| punctuation | #E1EFFF | — |
| punctuation.definition.parameters | #FFEE80 | — |
| punctuation.definition.template-expression | #FFEE80 | — |
| storage | #FAD000 | — |
| storage.type.function.arrow | #FAD000 | — |
| string, punctuation.definition.string | #A5FF90 | — |
| string.template, punctuation.definition.string.template | #3AD900 | — |
| support | #80FFBB | — |
| support.function | #FF9D00 | — |
| support.variable.property.dom | #9EFFFF | — |
| variable | #E1EFFF | — |
| source.ini entity, meta.embedded.block.ini, source.ini | #E1EFFF | — |
| source.ini keyword, keyword.other.definition.ini | #FAD000 | — |
| source.ini punctuation.definition | #FFEE80 | — |
| source.ini punctuation.separator, punctuation.separator.key-value.ini | #FF9D00 | — |
| source.css entity, source.stylus entity | #3AD900 | — |
| entity.other.attribute-name.class.css | #9EFFFF | — |
| entity.other.attribute-name.id.css, entity.other.attribute-name.pseudo-class.css | #FFB454 | — |
| entity.name.tag | #9EFFFF | — |
| source.css support, entity.name.tag.css, source.stylus support | #A5FF90 | — |
| source.css constant, source.css support.constant, source.stylus constant, source.stylus support.constant | #FFEE80 | — |
| source.css string, source.css punctuation.definition.string, source.stylus string, source.stylus punctuation.definition.string | #FFEE80 | — |
| source.css variable, source.stylus variable | #9EFFFF | — |
| text.html.basic entity.name, punctuation.definition.tag.html, entity.name.tag.inline.any.html, meta.tag.other.html, meta.tag.inline.any.html, punctuation.definition.tag.begin.html, punctuation.definition.tag.end.html, entity.name.tag, meta.tag.other.html, meta.tag.other.js, meta.tag.other.tsx, entity.name.tag.tsx, entity.name.tag.js, entity.name.tag, meta.tag.js, meta.tag.tsx, meta.tag.html | #9EFFFF | — |
| meta.toc-list.id.html | #A5FF90 | — |
| text.html.basic entity.other | #FAD000 | — |
| meta.tag.metadata.script.html entity.name.tag.html | #FAD000 | — |
| punctuation.definition.string.begin, punctuation.definition.string.end | #92FC79 | — |
| meta.tag.inline.any.html, meta.tag.other | #FF9D00 | — |
| source.json support | #FAD000 | — |
| source.json string, source.json punctuation.definition.string | #92FC79 | — |
| source.js storage.type.function | #FB94FF | — |
| variable.language, entity.name.type.class.js | #FB94FF | — |
| entity.other.inherited-class | #FFEE80 | — |
| storage.type.extends.js, storage.type.class.jsdoc | #FF9D00 | — |
| punctuation.definition.block.tag.jsdoc | #FF9D00 | — |
| variable.other.jsdoc, entity.name.type.instance.jsdoc | #9EFFFF | — |
| variable.other.constant | #9EFFFF | — |
| punctuation.definition.tag.begin.js, punctuation.definition.tag.end.js | #9EFFFF | — |
| meta.jsx.children.js | #FFFFFF | — |
| storage.type, storage.type.class, storage.modifier, keyword.control, keyword.operator | #FF9D00 | — |
| punctuation.definition.bracket.curly | #494685 | — |
| keyword.operator.assignment.tsx, keyword.operator.assignment.jsx | #FF9D00 | — |
| keyword.operator.assignment | #FF9D00 | — |
| meta.jsx.children.tsx | #FFFFFF | — |
| meta.object-literal.key.js | #80FFBB | — |
| entity.name.type.class.tsx, entity.name.type.class.jsx, variable.other.readwrite.alias.tsx, variable.other.readwrite.tsx, variable.other.readwrite.alias.ts, variable.other.readwrite.alias.jsx, variable.other.readwrite.alias.js, variable.other.object.tsx, variable.other.object.jsx, variable.other.object, support.class.component.tsx, support.class.component.jsx, entity.name.type.tsx, entity.name.type.jsx, variable.other.readwrite, variable.other.object.js | #9EFFFF | — |
| variable.other.property, variable.other.object.property | #FFEE80 | — |
| JSXNested | #FFFFFF | — |
| variable.parameter | #9EFFFF | — |
| variable.parameter.function.language.special.self.python | #9EFFFF | — |
| meta.function-call.python, meta.function-call.generic.python, support.function.builtin.python | #FAD000 | — |
| source.ts entity.name.type | #80FFBB | — |
| source.ts keyword | #FAD000 | — |
| source.ts punctuation.definition.parameters | #E1EFFF | — |
| meta.arrow.ts punctuation.definition.parameters | #FFEE80 | — |
| source.ts storage | #9EFFFF | — |
| entity.name.section.markdown, markup.heading.setext.1.markdown, markup.heading.setext.2.markdown | #FAD000 | bold |
| markup.inserted.diff, punctuation.definition.inserted.diff | #8efa00 | — |
| markup.deleted.diff, punctuation.definition.deleted.diff | #F16E6B | — |
| meta.embedded.block.diff | #FFFFFF | — |
| meta.paragraph.markdown | #FFFFFF | — |
| punctuation.definition.from-file.diff, meta.diff.header.from-file | #5706a2 | — |
| markup.inline.raw.string.markdown | #A599E9 | — |
| beginning.punctuation.definition.quote.markdown | #FAD000 | — |
| markup.quote.markdown meta.paragraph.markdown, punctuation.definition.quote.begin.markdown | #A599E9 | — |
| meta.separator.markdown | #FAD000 | — |
| markup.bold.markdown | — | bold |
| markup.italic.markdown | — | italic |
| beginning.punctuation.definition.list.markdown, punctuation.definition.list.begin.markdown, markup.list.unnumbered.markdown | #FAD000 | — |
| string.other.link.description.title.markdown punctuation.definition.string.markdown, meta.link.inline.markdown string.other.link.description.title.markdown, string.other.link.description.title.markdown punctuation.definition.string.begin.markdown, string.other.link.description.title.markdown punctuation.definition.string.end.markdown, meta.image.inline.markdown string.other.link.description.title.markdown | #A5FF90 | |
| meta.link.inline.markdown string.other.link.title.markdown, meta.link.reference.markdown string.other.link.title.markdown, meta.link.reference.def.markdown markup.underline.link.markdown | #FAD000 | underline |
| markup.underline.link.markdown, string.other.link.description.title.markdown | #A599E9 | — |
| fenced_code.block.language, markup.inline.raw.markdown | #9EFFFF | — |
| punctuation.definition.markdown, punctuation.definition.raw.markdown, punctuation.definition.heading.markdown, punctuation.definition.bold.markdown, punctuation.definition.italic.markdown | #494685 | — |
| meta.link.inline.markdown punctuation.definition.string.begin.markdown, meta.link.inline.markdown punctuation.definition.string.end.markdown, meta.link.reference.markdown punctuation.definition.string.begin.markdown, meta.link.reference.markdown punctuation.definition.string.end.markdown, string.other.link.description.markdown | #FAD000 | — |
| meta.image.inline.markdown punctuation.definition.string.begin.markdown, meta.image.inline.markdown punctuation.definition.string.end.markdown, string.other.link.description.markdown | #FF9D00 | — |
| markup.underline.link.markdown, punctuation.definition.metadata.markdown, markup.underline.link.image.markdown, constant.other.reference.link.markdown, punctuation.definition.constant.markdown, punctuation.definition.constant.begin.markdown, punctuation.definition.constant.end.markdown | #A599E9 | — |
| text.jade entity.name | #9EFFFF | — |
| storage.type.function.pug | #FF9D00 | — |
| variable.parameter.function.js | #9EFFFF | — |
| variable.control.import.include.pug | #92FC79 | — |
| text.jade string.interpolated | #FFEE80 | — |
| storage.type.cs | #9EFFFF | — |
| entity.name.variable.property.cs | #9EFFFF | — |
| storage.modifier.cs | #80FFBB | — |
| source.php entity, variable.other.class.php | #9EFFFF | — |
| keyword.other.phpdoc.php | #FF9D00 | — |
| entity.name.function.php, support.function.basic_functions.php, meta.function-call.php, variable.other.property | #FAD000 | — |
| variable.other.php, punctuation.definition.variable.php, variable.other.global.php, variable.language.this.php | #9EFFFF | — |
| storage.modifier.php, keyword.other.namespace.php | #FF9D00 | — |
| entity.name.tag.yaml | #FAD000 | — |
| punctuation.definition.block.sequence.item.yaml | #E1EFFF | — |
| storage.type.function.php, meta.function.parameters.php | #FB94FF | — |
| keyword.blade | #FF9D00 | — |
| begin.bracket.round.blade.php, end.bracket.round.blade.php | #E1EFFF | — |
| support.function.construct.begin.blade, support.function.construct.end.blade | #FFEE80 | — |
| keyword.package.go, keyword.import.go | #FF9D00 | — |
| keyword.function.go | #FB94FF | — |
| variable.other.assignment.go | #9EFFFF | — |
| punctuation.definition.string.begin.go, punctuation.definition.string.end.go, support.function.go | #FAD000 | — |
| punctuation.section.embedded.end.ruby, punctuation.section.embedded.begin.ruby, punctuation.section.scope.begin.ruby, punctuation.section.scope.end.ruby | #FFEE80 | — |
| variable.other.constant.ruby | #80FFBB | — |
| entity.name.type.class.ruby | #FB94FF | — |
| variable.other.block.ruby, variable.other.ruby | #9EFFFF | — |
| punctuation.separator.other.ruby | #FF9D00 | — |
| keyword.other.special-method.ruby | #FFEE80 | — |
| storage.type.function.shell | #FB94FF | — |
| variable.other.special.shell, punctuation.definition.variable.shell | #FF9D00 | — |
| variable.graphql | #FAEFA5 | — |
| keyword.operation.graphql | #FB94FF | — |
| source.sql | #E1EFFF | — |
| source.sql keyword.other, support.function.mysqli.php | #FAEFA5 | — |
| support.function.mysqli.php, source.sql support.function | #FAD000 | — |
| string.regexp, string.regexp keyword.other | #E1EFFF | — |
| keyword.other.DML.sql | #FF9D00 | — |
| punctuation.definition.table.array.toml | #E1EFFF | — |
| entity.other.attribute-name.table.array.toml, entity.other.attribute-name.table.toml | #FF9D00 | — |
| keyword.key.toml | #FAD000 | — |
| keyword.other.special-method.dockerfile | #FAD000 | — |
| keyword.other.rust | #FF9D00 | — |
| keyword.other.fn.rust | #FB94FF | — |
| keyword.other.env | #FF9D00 | — |
| variable.other.env | #FAD000 | — |
| source.env | #E1EFFF | — |
| keyword.other.template.begin.env, keyword.other.template.end.env, keyword.operator.assignment.env | #FF9D00 | — |
| variable.object.property | #9EFFFF | — |
| string.regexp.js | #FB94FF | — |
| keyword.rainbow2 | #FF9D00 | — |
| keyword.other.nim, keyword.other | #FF9D00 | — |
| keyword.boolean | #FF628C | — |
| punctuation.pragma.start.nim, punctuation.pragma.end.nim, entity.name.function.nim | #fad000 | — |
| markup.deleted | #F16E6B | — |
| markup.inserted | #8efa00 | — |
| markup.underline | — | underline |
| modifier, this, comment, storage.modifier, entity.other.attribute-name, entity.other.attribute-name.html, punctuation.definition.comment, text.html.basic entity.other, entity.other.attribute-name, markup.quote.markdown meta.paragraph.markdown, markup.italic.markdown, text.jade entity.other.attribute-name.tag, keyword.control.from, entity.other.attribute-name.tag.pug | — | italic |
Full workbench mockup using this variant's colors and tokenColors.
Loading...
Workbench UI color keys from the theme JSON colors map.
TextMate scopes and font styles (syntax highlighting rules).
| scope | foreground | fontStyle |
|---|---|---|
| — | #002339 | — |
| meta.paragraph.markdown, string.other.link.description.title.markdown | #110000 | — |
| entity.name.section.markdown, punctuation.definition.heading.markdown | #034c7c | — |
| punctuation.definition.string.begin.markdown, punctuation.definition.string.end.markdown, markup.quote.markdown | #00AC8F | — |
| markup.quote.markdown | #003494 | italic |
| markup.bold.markdown, punctuation.definition.bold.markdown | #4e76b5 | bold |
| markup.italic.markdown, punctuation.definition.italic.markdown | #C792EA | italic |
| markup.inline.raw.string.markdown, markup.fenced_code.block.markdown | #0460b1 | italic |
| punctuation.definition.metadata.markdown | #00AC8F | — |
| markup.underline.link.image.markdown, markup.underline.link.markdown | #924205 | — |
| comment | #357b42 | italic |
| string | #a44185 | — |
| constant.numeric | #174781 | — |
| constant | #174781 | — |
| language.method | #174781 | — |
| constant.character, constant.other | #174781 | — |
| variable | #2f86d2 | |
| variable.language.this | #000000 | |
| keyword | #7b30d0 | |
| storage | #da5221 | |
| storage.type | #0991b6 | |
| entity.name.class | #1172c7 | — |
| entity.other.inherited-class | #b02767 | |
| entity.name.function | #7eb233 | |
| variable.parameter | #b1108e | |
| entity.name.tag | #0444ac | |
| text.html.basic | #0071ce | |
| entity.name.type | #0444ac | — |
| entity.other.attribute-name | #df8618 | italic |
| support.function | #1ab394 | |
| support.constant | #174781 | |
| support.type, support.class | #dc3eb7 | — |
| support.other.variable | #224555 | — |
| invalid | #207bb8 | italic bold underline |
| invalid.deprecated | #207bb8 | bold italic underline |
| source.json support | #6dbdfa | — |
| source.json string, source.json punctuation.definition.string | #00820f | — |
| markup.list | #207bb8 | — |
| markup.heading punctuation.definition.heading, entity.name.section | #4FB4D8 | |
| text.html.markdown meta.paragraph meta.link.inline, text.html.markdown meta.paragraph meta.link.inline punctuation.definition.string.begin.markdown, text.html.markdown meta.paragraph meta.link.inline punctuation.definition.string.end.markdown | #87429A | — |
| markup.quote | #87429A | — |
| markup.bold | #08134A | bold |
| markup.italic, punctuation.definition.italic | #174781 | italic |
| meta.link | #87429A | — |
Full workbench mockup using this variant's colors and tokenColors.
Loading...
Workbench UI color keys from the theme JSON colors map.
TextMate scopes and font styles (syntax highlighting rules).
| scope | foreground | fontStyle |
|---|---|---|
| meta.embedded, source.groovy.embedded | #D4D4D4 | — |
| emphasis | — | italic |
| strong | — | bold |
| header | #000080 | — |
| comment | #6A9955 | — |
| constant.language | #569cd6 | — |
| constant.numeric | #b5cea8 | — |
| constant.regexp | #646695 | — |
| entity.name.tag | #569cd6 | — |
| entity.name.tag.css | #d7ba7d | — |
| entity.other.attribute-name | #9cdcfe | — |
| entity.other.attribute-name.class.css, entity.other.attribute-name.class.mixin.css, entity.other.attribute-name.id.css, entity.other.attribute-name.parent-selector.css, entity.other.attribute-name.pseudo-class.css, entity.other.attribute-name.pseudo-element.css, source.css.less entity.other.attribute-name.id, entity.other.attribute-name.attribute.scss, entity.other.attribute-name.scss | #d7ba7d | — |
| invalid | #f44747 | — |
| markup.underline | — | underline |
| markup.bold | #569cd6 | bold |
| markup.heading | #569cd6 | bold |
| markup.italic | — | italic |
| markup.inserted | #b5cea8 | — |
| markup.deleted | #ce9178 | — |
| markup.changed | #569cd6 | — |
| punctuation.definition.quote.begin.markdown | #6A9955 | — |
| punctuation.definition.list.begin.markdown | #6796e6 | — |
| markup.inline.raw | #ce9178 | — |
| punctuation.definition.tag | #808080 | — |
| meta.preprocessor | #569cd6 | — |
| meta.preprocessor.string | #ce9178 | — |
| meta.preprocessor.numeric | #b5cea8 | — |
| meta.structure.dictionary.key.python | #9cdcfe | — |
| meta.diff.header | #569cd6 | — |
| storage | #569cd6 | — |
| storage.type | #569cd6 | — |
| storage.modifier | #569cd6 | — |
| string | #ce9178 | — |
| string.tag | #ce9178 | — |
| string.value | #ce9178 | — |
| string.regexp | #d16969 | — |
| punctuation.definition.template-expression.begin, punctuation.definition.template-expression.end, punctuation.section.embedded | #569cd6 | — |
| meta.template.expression | #d4d4d4 | — |
| support.type.vendored.property-name, support.type.property-name, variable.css, variable.scss, variable.other.less, source.coffee.embedded | #9cdcfe | — |
| keyword | #569cd6 | — |
| keyword.control | #569cd6 | — |
| keyword.operator | #d4d4d4 | — |
| keyword.operator.new, keyword.operator.expression, keyword.operator.cast, keyword.operator.sizeof, keyword.operator.instanceof, keyword.operator.logical.python | #569cd6 | — |
| keyword.other.unit | #b5cea8 | — |
| punctuation.section.embedded.begin.php, punctuation.section.embedded.end.php | #569cd6 | — |
| support.function.git-rebase | #9cdcfe | — |
| constant.sha.git-rebase | #b5cea8 | — |
| storage.modifier.import.java, variable.language.wildcard.java, storage.modifier.package.java | #d4d4d4 | — |
| variable.language | #569cd6 | — |
| entity.name.function, support.function, support.constant.handlebars | #DCDCAA | — |
| meta.return-type, support.class, support.type, entity.name.type, entity.name.class, storage.type.numeric.go, storage.type.byte.go, storage.type.boolean.go, storage.type.string.go, storage.type.uintptr.go, storage.type.error.go, storage.type.rune.go, storage.type.cs, storage.type.generic.cs, storage.type.modifier.cs, storage.type.variable.cs, storage.type.annotation.java, storage.type.generic.java, storage.type.java, storage.type.object.array.java, storage.type.primitive.array.java, storage.type.primitive.java, storage.type.token.java, storage.type.groovy, storage.type.annotation.groovy, storage.type.parameters.groovy, storage.type.generic.groovy, storage.type.object.array.groovy, storage.type.primitive.array.groovy, storage.type.primitive.groovy | #4EC9B0 | — |
| meta.type.cast.expr, meta.type.new.expr, support.constant.math, support.constant.dom, support.constant.json, entity.other.inherited-class | #4EC9B0 | — |
| keyword.control | #C586C0 | — |
| variable, meta.definition.variable.name, support.variable, entity.name.variable | #9CDCFE | — |
| meta.object-literal.key | #9CDCFE | — |
| support.constant.property-value, support.constant.font-name, support.constant.media-type, support.constant.media, constant.other.color.rgb-value, constant.other.rgb-value, support.constant.color | #CE9178 | — |
| punctuation.definition.group.regexp, punctuation.definition.group.assertion.regexp, punctuation.definition.character-class.regexp, punctuation.character.set.begin.regexp, punctuation.character.set.end.regexp, keyword.operator.negation.regexp, support.other.parenthesis.regexp | #CE9178 | — |
| constant.character.character-class.regexp, constant.other.character-class.set.regexp, constant.other.character-class.regexp, constant.character.set.regexp | #d16969 | — |
| keyword.operator.or.regexp, keyword.control.anchor.regexp | #DCDCAA | — |
| keyword.operator.quantifier.regexp | #d7ba7d | — |
| constant.character | #569cd6 | — |
| constant.character.escape | #d7ba7d | — |
| token.info-token | #6796e6 | — |
| token.warn-token | #cd9731 | — |
| token.error-token | #f44747 | — |
| token.debug-token | #b267e6 | — |
Full workbench mockup using this variant's colors and tokenColors.
Loading...
Workbench UI color keys from the theme JSON colors map.
TextMate scopes and font styles (syntax highlighting rules).
| scope | foreground | fontStyle |
|---|---|---|
| — | #002339 | — |
| meta.paragraph.markdown, string.other.link.description.title.markdown | #110000 | — |
| entity.name.section.markdown, punctuation.definition.heading.markdown | #034c7c | — |
| punctuation.definition.string.begin.markdown, punctuation.definition.string.end.markdown, markup.quote.markdown | #00AC8F | — |
| markup.quote.markdown | #003494 | italic |
| markup.bold.markdown, punctuation.definition.bold.markdown | #4e76b5 | bold |
| markup.italic.markdown, punctuation.definition.italic.markdown | #C792EA | italic |
| markup.inline.raw.string.markdown, markup.fenced_code.block.markdown | #0460b1 | italic |
| punctuation.definition.metadata.markdown | #00AC8F | — |
| markup.underline.link.image.markdown, markup.underline.link.markdown | #924205 | — |
| comment | #357b42 | italic |
| string | #a44185 | — |
| constant.numeric | #174781 | — |
| constant | #174781 | — |
| language.method | #174781 | — |
| constant.character, constant.other | #174781 | — |
| variable | #2f86d2 | |
| variable.language.this | #000000 | |
| keyword | #7b30d0 | |
| storage | #da5221 | |
| storage.type | #0991b6 | |
| entity.name.class | #1172c7 | — |
| entity.other.inherited-class | #b02767 | |
| entity.name.function | #7eb233 | |
| variable.parameter | #b1108e | |
| entity.name.tag | #0444ac | |
| text.html.basic | #0071ce | |
| entity.name.type | #0444ac | — |
| entity.other.attribute-name | #df8618 | italic |
| support.function | #1ab394 | |
| support.constant | #174781 | |
| support.type, support.class | #dc3eb7 | — |
| support.other.variable | #224555 | — |
| invalid | #207bb8 | italic bold underline |
| invalid.deprecated | #207bb8 | bold italic underline |
| source.json support | #6dbdfa | — |
| source.json string, source.json punctuation.definition.string | #00820f | — |
| markup.list | #207bb8 | — |
| markup.heading punctuation.definition.heading, entity.name.section | #4FB4D8 | |
| text.html.markdown meta.paragraph meta.link.inline, text.html.markdown meta.paragraph meta.link.inline punctuation.definition.string.begin.markdown, text.html.markdown meta.paragraph meta.link.inline punctuation.definition.string.end.markdown | #87429A | — |
| markup.quote | #87429A | — |
| markup.bold | #08134A | bold |
| markup.italic, punctuation.definition.italic | #174781 | italic |
| meta.link | #87429A | — |
export interface User {
id: string;
name: string;
role: "admin" | "member";
tags: string[];
}
/**
* Fetch user data by ID
* @param id
* @returns User object or null if ID is invalid
*/
export async function fetchUser(id: string): Promise<User | null> {
if (!id) {
return null;
}
const response = await fetch(`/api/users/${id}`, {
method: "GET",
headers: { Accept: "application/json" },
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return (await response.json()) as User;
}
function greet(user: User): string {
// Simple greeting function that uses the user's name
return `Hello, ${user.name}!`;
}
export interface User {
id: string;
name: string;
role: "admin" | "member";
tags: string[];
}
/**
* Fetch user data by ID
* @param id
* @returns User object or null if ID is invalid
*/
export async function fetchUser(id: string): Promise<User | null> {
if (!id) {
return null;
}
const response = await fetch(`/api/users/${id}`, {
method: "GET",
headers: { Accept: "application/json" },
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return (await response.json()) as User;
}
function greet(user: User): string {
// Simple greeting function that uses the user's name
return `Hello, ${user.name}!`;
}
export interface User {
id: string;
name: string;
role: "admin" | "member";
tags: string[];
}
/**
* Fetch user data by ID
* @param id
* @returns User object or null if ID is invalid
*/
export async function fetchUser(id: string): Promise<User | null> {
if (!id) {
return null;
}
const response = await fetch(`/api/users/${id}`, {
method: "GET",
headers: { Accept: "application/json" },
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return (await response.json()) as User;
}
function greet(user: User): string {
// Simple greeting function that uses the user's name
return `Hello, ${user.name}!`;
}
export interface User {
id: string;
name: string;
role: "admin" | "member";
tags: string[];
}
/**
* Fetch user data by ID
* @param id
* @returns User object or null if ID is invalid
*/
export async function fetchUser(id: string): Promise<User | null> {
if (!id) {
return null;
}
const response = await fetch(`/api/users/${id}`, {
method: "GET",
headers: { Accept: "application/json" },
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return (await response.json()) as User;
}
function greet(user: User): string {
// Simple greeting function that uses the user's name
return `Hello, ${user.name}!`;
}