-
-
Notifications
You must be signed in to change notification settings - Fork 762
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: server support custom name #87
feat: server support custom name #87
Conversation
First of all thank you! Here I see that we can have different cases of problems that may have given that the appName refers to the name of the docker container. Example: We create a project called: dokploy
I would propose 2 ways Give multiple options to choose in the appName:
|
I think the second option is much more relevant; however, you could combine both solutions. Using random names makes app setup and debugging more challenging because you can't identify what each service does. But if we use names like 'myproject-myservice-', it could be sufficient. This approach requires more thought. |
It is a good idea, and currently is very difficult to debug an application with a random name. I think that doing it this way would make it more specific myproject-[app|pg|mongo|redis|mariadb|mysql]-myservice-hash examples:
|
I don't think it's necessary to specify the type of service in its name. In a project, you shouldn't give the same name to two different services |
Yes but we are back to the same problem you assume that it wouldn't happen because you surely wouldn't do it, but someone is very sure that they can do it, but let's do it that way. Also currently when creating a project we don't apply any validation, so the user can write any project name, also that make kinda dificult to implement this feature, because we need to validate from the creation of the project and apply some regex validation to not include certain values like But yeah the validation could be like this
the hash would be ideal around 7 characters
and for regular expression could be something like |
@Siumauricio @TheoCouss Is this okay?
✅ demo
✅ d1
✅ d-1-d
✅ d-000
✅ ok-ok-ok
🔴 1
🔴 -ok
🔴 ok-1-
🔴 1ok
🔴 ok-ok-
🔴 -ok- |
Looks good @hehehai , can you try this input? |
@Siumauricio Yes, case is currently supported. You mean capitalized cases should not be supported?
✅ demo
✅ d1
✅ d-1-d
✅ d-000
✅ ok-ok-ok
🔴 1
🔴 -ok
🔴 ok-1-
🔴 1ok
🔴 ok-ok-
🔴 -ok-
🔴 oK
🔴 OK
🔴 OK-1 |
@hehehai Also this case is working |
why? Is it the number at the end? |
Correct |
yeah that looks good |
77ffc9c
to
324ba24
Compare
CleanShot.2024-05-23.at.16.26.41.mp4 |
324ba24
to
fae180f
Compare
onChange={(e) => { | ||
const val = e.target.value?.trim() || ""; | ||
form.setValue("appName", `${projectName}-${val}`); | ||
field.onChange(val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix: Value changes do not trigger verification
@@ -49,6 +49,9 @@ export const mariadbRouter = createTRPCRouter({ | |||
|
|||
return true; | |||
} catch (error) { | |||
if (error instanceof TRPCError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix:Error messages are not directly thrown to prevent server error sensitive information from appearing on the client
@@ -73,3 +82,41 @@ export const updateProjectById = async ( | |||
|
|||
return result; | |||
}; | |||
|
|||
export const validUniqueServerAppName = async (appName: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hehehai since you just validate and throw an error, what do you think of this proposal?
// Usage
await validUniqueServerAppNameOrThrow(input.appName);
export const validUniqueServerAppNameOrThrow = async (appName?: string) => {
if (!appName) return;
const query = await db.query.projects.findMany({
with: {
applications: {
where: eq(applications.appName, appName),
},
mariadb: {
where: eq(mariadb.appName, appName),
},
mongo: {
where: eq(mongo.appName, appName),
},
mysql: {
where: eq(mysql.appName, appName),
},
postgres: {
where: eq(postgres.appName, appName),
},
redis: {
where: eq(redis.appName, appName),
},
},
});
// Filter out items with non-empty fields
const nonEmptyProjects = query.filter(
(project) =>
project.applications.length > 0 ||
project.mariadb.length > 0 ||
project.mongo.length > 0 ||
project.mysql.length > 0 ||
project.postgres.length > 0 ||
project.redis.length > 0
);
if (nonEmptyProjects.length > 0) {
throw new TRPCError({
code: "CONFLICT",
message: "Service with this 'AppName' already exists",
});
}
};
Thanks to everyone! |
done: #39
CleanShot.2024-05-15.at.19.18.33.mp4